Ruby AdWords API Returning AuthenticationError.OAUTH_TOKEN_HEADER_INVALID

1

I'm using:

  • devise
  • omniauth
  • omniauth-google-oauth2
  • google-adwords-api

I get the token from the oauth callback:

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 for 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 fetch 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 causes this error to occur? and how to fix it?

    
asked by anonymous 09.01.2015 / 17:56

0 answers