Creating a Custom OAuth App
When to Create a Custom OAuth App
CData embeds OAuth Application Credentials with CData branding that can be used when connecting via a desktop application or headless application. Web applications require a custom OAuth application. You may choose to use your own OAuth Application Credentials when you want to- control branding of the Authentication Dialog
- control the redirect URI that the application redirects the user to after the user authenticates
- customize the permissions that you are requesting from the user
Allow Access to Instagram Data
To allow users to connect through the connector, complete the tasks below:
- Connect a Facebook Page to an Instagram account.
- Create and register the connector as an app with Instagram.
- Submit your app for Facebook's review.
Connect a Facebook Page to an Instagram Account
To access Instagram data, users need a role on a page that is associated with an Instagram account. Any user with a role on the page has access.
To connect a page and an Instagram account, log into Facebook and from your Page's settings, click Instagram, and log into your Instagram account. If your account is not an Instagram Business Account, follow the prompts to set up a business profile.
Create and Register the App
Register an app to obtain the values for the OAuthClientId and OAuthClientSecret properties. The OAuth client credentials authenticate the connector to Facebook.
- Log into Facebook and navigate to https://developers.facebook.com/apps.
- Create a new app and click Settings > Basic. The OAuthClientId is the App Id displayed. The OAuthClientSecret is the App Secret.
- Click Add Platform and select Website. Enter a Site URL. This value is not used in authentication.
Follow these steps to configure the OAuth redirect URI.
- Go to your app settings and add the Facebook Login product from the "Products" section.
- In the product settings, define the OAuth redirect URI.
If you are building a desktop application, set the redirect URI to https://localhost:33333/, or a similar https url.
If you are building a web application, set the redirect URI you want to be used as the callback URL that users return to with the token that verifies that they have granted your app access.
Add the Instagram API Product
Follow these steps to configure the Instagram API permissions your app requests:
- Go to your app settings and add the Instagram product from the "Products" section.
- Configure the permissions in the product settings. To access all the tables and views, include the following scopes:
- instagram_basic
- instagram_manage_comments
- instagram_manage_insights
See the Data Model section for detailed information about the scopes required for specific tables.
Submit the App for Review to Go Live
While you can still with an application without review, to go live and fully access Instagram content, you must submit your application for review and approval.
- Click Manage for your application and on the Permissions tab click Start a Submission.
- Select the use case that best describes your Instagram integration.
- Fill in the form and wait for your application to be approved.
Authenticate to Instagram
Desktop Applications
After setting the following connection properties, you are ready to connect:
- OAuthClientId: Set this to the App Id for your OAuth app.
- OAuthClientSecret: Set this to the App Secret for your OAuth app.
- InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- BusinessAccountId: If you have more than one Facebook page connected with an Instagram account, set the BusinessAccountId connection property to specify the Id of a business account you have associated with a Facebook page.
You can get a business account Id by querying the Page view.
- Extracts the access token from the callback URL and authenticates requests.
- Obtains a new access token when the old one expires.
- Saves OAuth values in OAuthSettingsLocation. These values persist across connections.
Web Applications
Follow the steps below to use the connector to get the OAuth token values and connect from a web application. Get an Access Token
Set the following connection properties to obtain the OAuthAccessToken:
- OAuthClientId: Set this to the App Id in your app settings.
- OAuthClientSecret: Set this to the App Secret in your app settings.
Then follow these steps to complete the OAuth exchange:
- Call the GetOAuthAuthorizationURL stored procedure. Set the AuthMode input to WEB and set the CallbackURL input to the OAuth redirect URI you specified in your app settings. The stored procedure returns the URL to the OAuth endpoint.
- Log in and authorize the application. You are redirected back to the callback URL.
The callback URL contains the verifier code in a query string parameter. Extract the verifier code from the callback URL.
- Set the following parameters and call GetOAuthAccessToken:
Name Value AuthMode WEB Verifier Set this to the verifier code. CallbackURL Set this to the callback URL in your app settings.
Connect to Multiple Pages
If you have more than one Facebook page connected with an Instagram business account, set BusinessAccountId in addition to OAuthAccessToken. The BusinessAccountId property specifies the Id of a business account you have associated with a Facebook page.
You can get a business account Id by querying the Page View.