node-mailchimp icon indicating copy to clipboard operation
node-mailchimp copied to clipboard

Access Token support?

Open jonton11 opened this issue 9 years ago • 4 comments

Does this API wrapper support using access tokens via OAuth for the api_key? I keep getting missing or invalid api key error when I attempt to.

jonton11 avatar Jan 10 '17 22:01 jonton11

It does not currently support that. I have not used the API with OAuth, and don't know what it takes to implement it.

I will be happy to accept a PR for it. It might be as easy as changing the constructor to accept an optional DC argument, as this is currently parsed from the api key.

thorning avatar Jan 11 '17 08:01 thorning

I added a issue for browser side support, and closing the related tasks

thorning avatar May 02 '17 18:05 thorning

Reopened, as relevant server side

thorning avatar May 15 '17 09:05 thorning

See: https://developer.mailchimp.com/documentation/mailchimp/guides/how-to-use-oauth2/

The access_token is used as an API key. Users don’t have access to these keys because they are tied directly to your application. But, the user can de-authorize your application in MailChimp, which removes and invalidates the token.

If you GET /oauth2/metadata:

{"dc":"us1","login_url":"https:\/\/login.mailchimp.com","api_endpoint":"https:\/\/us1.api.mailchimp.com"}

And concatenate the accessToken and the datacenter, ${accessToken}-${dc}, you should be able to pass this right to mailchimp as the api key.

ferrants avatar Mar 06 '18 22:03 ferrants