AdWords API Advisor.
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.
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?