カスタムOAuth アプリケーションの作成
Creating a Custom OAuth Application
CData embeds OAuth Application Credentials with CData branding that can be used when connecting to Square via a desktop application or a headless machine. If you want to use the embedded OAuth application, all you need to do to connect is to:- set AuthScheme to OAuth,
- get and set the OAuthAccessToken, and
- set the necessary configuration parameters.
(For information on getting and setting the OAuthAccessToken and other configuration parameters, see the Desktop Authentication section of "Connecting to Square".)
However, you must create a custom OAuth application to connect to Square via the Web. And since custom OAuth applications seamlessly support all three commonly-used auth flows, you might want to create custom OAuth applications (use your own OAuth Application Credentials) for those auth flows anyway.
Custom OAuth applications are useful if you want to:
- control branding of the authentication dialog;
- control the redirect URI that the application redirects the user to after the user authenticates; or
- customize the permissions that you are requesting from the user.
To register a custom OAuth app and obtain the OAuth client credentials, the Application Id and Application Secret:
- Log in with a Square account.
- Navigate to the Developer Dashboard at "https://developer.squareup.com/apps".
- Create a new application:
- Enter a name to be displayed to users when they log in to grant permissions to your app.
- Click Create App.
- If this will be a desktop application, set the Redirect URL, on the OAuth tab, to http://localhost:33333 or a different port number of your choice.
- If this will be a Web application, navigate to the OAuth tab and set the Redirect URL to a page on your Web app you would like the user to be returned to after they have authorized your application.
- Set CallbackURL to be equal to the value of the Redirect URL you just specified.
- Set OAuthClientId to the Application Id for the application you just created, as found on the Credentials page.
- Set OAuthClientSecret to the Application Secret for the application you just created, as found on the OAuth tab.