Re: AdWords API oauth2.0 redirect mismatch uri

394 views
Skip to first unread message

Anash P. Oommen (AdWords API Team)

unread,
May 24, 2013, 10:39:13 AM5/24/13
to adwor...@googlegroups.com
Hi Christopher,

Have you provided oauth2_callback key in your adwords.yml? And does that match the one you provided in the API console?

Cheers,
Anash P. Oommen,
AdWords API Advisor.

On Thursday, May 23, 2013 1:29:10 PM UTC+5:30, Christopher Sell wrote:
I am using the google-api-ads-ruby and oauth 2.0 to have users authenticate and then make calls on their behalf to pull reports about their AdWords account.

I have Oauth 2.0 fully set up for Google Analytics and it works.
Next I added Google AdWords to the scope.
I redirect the user to get approval.
When they return I take the verification code in the parameter on the callback and store it in my database.
That all works great.

But, here is where I am falling flat:
When I try to create a call on the user's behalf I get:
AdsCommon::Errors::AuthError: Authorization error occured: Authorization failed.  Server message:
{
  "error" : "redirect_uri_mismatch"
}


Here is my code for the method I am using to call the API:
    config_filename = File.join(Rails.root, 'config', 'adwords_api.yml')
    adwords = AdwordsApi::Api.new(config_filename)
    api_version = :v201306
    token = adwords.authorize({:oauth2_verification_code => google_authentication.verification_code})
    campaign_srv = adwords.service(:CampaignService, api_version)

It is failing on the adwords.authorize line. 
My local redirect uri in the api console is: http://127.0.0.1:3000/users/auth/google_oauth2/callback
This redirect uri works for authorizing the user using omniauth the first go around, but not when I am using the google-api-ads-ruby gem to make calls to the API.

Any ideas on how I can go about fixing this?

Christopher Sell

unread,
May 24, 2013, 12:49:18 PM5/24/13
to adwor...@googlegroups.com
Just did, and that works. Thanks so much Anash!
Reply all
Reply to author
Forward
0 new messages