Implement mailchimp oauth2 authentication

Viewed 164

I want to implement mailchimp oauth2 authentication. I am reading here https://mailchimp.com/developer/release-notes/stricter-rules-for-url-matching-oauth-2/ that only support exact matching on the redirect URI My question is simple, how would I know which user is the one that actually authorizes my application. When I am trying to add the current user id I am getting an error

    call_back_url = url_for(controller: '/webhooks/mailchimp', action: 'handler', only_path: false, id: current_user.id)
Error call back uri mismatch.

Is there another way to add info about the user on the webhook callback?

1 Answers

I have found out how, I can add a state param on the redirect_to url, and then this is available on the webhook callback.

    query_params = "response_type=code&client_id=#{client_id}&redirect_uri=#{call_back_url}&state=#{current_user.id}"
Related