Ruby Adwords API returning Authenticationerror.OAUTH_TOKEN_HEADER_INVALID

Asked

Viewed 56 times

1

I’m using:

  • gift
  • omniauth
  • omniauth-google-Oauth2
  • google-Adwords-api

and catch the token by the callback of the oauth:

class OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def google_oauth2
    session[:token] = request.env["omniauth.auth"].credentials
    ...
  end
end

I’m following the example of Adwords on Rails to instantiate the API

 def adwords_api
   @api ||= create_adwords_api
 end

 def create_adwords_api
   api = AdwordsApi::Api.new Rails.application.config_for(:adwords)

   token = session[:token]
   if token
     credentials = api.credential_handler
     credentials.set_credential :oauth2_token, token
     credentials.set_credential :client_customer_id, current_user.id
   end
   api
 end

But when I try to search the campaigns this error appears: [AuthenticationError.OAUTH_TOKEN_HEADER_INVALID @ ; trigger:'<null>'

and based on the log, this is the url of the request:
[2015-01-09T10:12:44.237172 #6481] DEBUG -- : SOAP request: https://adwords.google.com/api/adwords/cm/v201409/CampaignService

what makes this error occur? and how to fix?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.