This question relates to refreshing an oauth token in the Google Adwords 
API v201206 using the PHP client library found in aw_api_php_lib_3.1.1 
here http://code.google.com/p/google-api-adwords-php/downloads/list

Everything works as expected till the token expires after 1 hour.

Attempting to refresh the token using the 
$user->RefreshOAuth2AccessToken($credentials) results in an error: 
invalid_grant

The method in question is RefreshAccessToken in SimpleOAuth2Handler.php

The refresh token method uses curl to post the following data to 
https://accounts.google.com/o/oauth2/token

(I've masked the start of the real data using **)
  [refresh_token] => **************vk_9xHqDzT2j8OrR-UW24
  [client_id] => ******googleusercontent.com
  [client_secret] => *******************RPd1o
  [grant_type] => refresh_token


This is the curlinfo

    [url] => https://accounts.google.com/o/oauth2/token
    [content_type] => application/json
    [http_code] => 400
    [header_size] => 378
    [request_size] => 249
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 1.735994
    [namelookup_time] => 0.598276
    [connect_time] => 0.616033
    [pretransfer_time] => 0.684525
    [size_upload] => 574
    [size_download] => 51
    [speed_download] => 29
    [speed_upload] => 330
    [download_content_length] => -1
    [upload_content_length] => 574
    [starttransfer_time] => 1.685787
    [redirect_time] => 0
    [request_header] => POST /o/oauth2/token HTTP/1.1
User-Agent: curl, gzip
Host: accounts.google.com
Accept: */*
Accept-Encoding: gzip
Content-Length: 574
Expect: 100-continue
Content-Type: multipart/form-data; 
boundary=----------------------------08f82c0f8254

Searching Google returns suggestions to check the time, but  my laptop is 
within 1 second of the unix timestamp so I don't think it's this.

I'd value your thoughts as I've had a rather frustrating time trying to get 
this to work.

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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