Creating a Custom OAuth App
There are two authentication methods available for connecting to Mailchimp: You can use the APIKey or use OAuth.
Using the API Key to Connect to Mailchimp
The APIKey grants full access to your MailChimp account. To obtain the APIKey, log into Mailchimp and click Account -> Extras -> API Keys.
Using OAuth to Connect to Mailchimp
OAuth requires the authenticating user to interact with Mailchimp using the browser. The driver facilitates this in various ways as described in the following sections.
Register Your Application
Follow the steps below to obtain the OAuth client credentials, the OAuthClientId and OAuthClientSecret:
- Log into your Mailchimp account and click Account -> Extras -> API Keys -> Register and Manage Your Apps.
- Enter the information you want to be displayed to users when they are prompted to grant permissions to your application. This information includes your app name, company, and website.
- If you are making a desktop application, in the Redirect URI box enter http://127.0.0.1.
If you are making a Web application, in the Redirect URI box enter a URL where you would like users to be redirected after they grant permissions to your application.
Authenticate to Mailchimp from a Desktop Application
After setting the following connection properties, you are ready to connect:
- OAuthClientId: Set this to the client Id in your app settings.
- OAuthClientSecret: Set this to the client secret in your app settings.
- CallbackURL: Set this to the redirect URI in your app settings.
- InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken connection property.
- Extracts the access token from the callback URL and authenticates requests.
- Refreshes the access token when it expires.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
Authenticate to Mailchimp from a Web Application
To obtain the access token, set the following connection properties:
- OAuthClientId: Set this to the client Id in your app settings.
- OAuthClientSecret: Set this to the client secret in your app settings.
- CallbackURL: Set this to the redirect URI in your app settings.
- Call GetOAuthAuthorizationURL. The URL of the Mailchimp OAuth endpoint is returned by the stored procedure.
-
In your Web browser, log in and authorize the application. The Mailchimp server then redirects you back via the callback URL.
The verifier code is appended to the callback URL in a query string parameter named "code". Extract the verifier code from the callback URL.
- Call GetOAuthAccessToken.