Hello Thomas,

You can request an authorization and get token this way (in the callback):

token = api.authorize({:oauth_request_token => 
request_token, :oauth_verification_code => params[:oauth_verifier]})
session[:token] = session[:token]

Here is how I re-create the API object from the session:

api = AdwordsApi::Api.new(config_filename)
token = session[:token]
# If we have an OAuth token in session we use the credentials from it.
if token
  credentials = api.credential_handler()
  credentials.set_credential(:oauth_token, token.token)
  credentials.set_credential(:oauth_token_secret, token.secret)
  # You may want to restore the CID as well
  credentials.set_credential(:client_customer_id, selected_account)
end

Depending on how you store the session you may want to store just 2 strings 
instead of the full token object.


-Danial, AdWords API Team.


On Wednesday, May 30, 2012 1:41:43 PM UTC+4, Thomas wrote:
>
> Hello,
>
> I'm trying to work out how to use OAuth with the Google Adwords API. Sofar 
> I didn't have much luck. While using ClientLogin is working perfect, OAuth 
> will always throw "AuthenticationError.OAUTH_TOKEN_INVALID".
>
> I tried my best to stay as close to the Ruby-Example in v201109_01 as 
> possible, but still no luck.
>
> What works:
>
> 1) Making a request against the API with OAuth returns 
> an AdsCommon::Errors::OAuthVerificationRequired Error.
> 2) Using the provided URL to redirect the user to the authentication page 
> (why not provide the redirection URL in the ruby example?)
>
> Now it stops working: I set the verification code like so (like in the 
> example): credential_handler.set_credential(:oauth_verification_code, 
> options[:oauth_verification_code]).
> Now doing a new request results in AuthenticationError.OAUTH_TOKEN_INVALID.
>
> I honestly couldn't get it to work. My questions:
>
> 1) Could it have something todo with the account I'm using to allow access 
> to Adwords? I'm using an MCC-Account with administration rights.
> 2) Why is the ruby implementation so different from phyton or php? 
> (UpgradeAuthToken?)
>
> I'm really at a loss here.
>
> Best regards
>   Thomas
>
>

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

Reply via email to