Refreshing a Token with php api

37 views
Skip to first unread message

James Andrews

unread,
Dec 22, 2015, 3:25:30 PM12/22/15
to AdWords API Forum
I've been poking through the API and have found various functions in different places that look like they are involved in refreshing tokens.  Nothing I am doing is working.

My code as follows

            // oauth 2 config
            $credentials= array(
              'client_id' => $config['id'],
              'client_secret' => $config['secret'],
              'access_token' => $params['access_token'],
              'refresh_token' => $params['refresh_token']
            );

            $user = new \AdWordsUser(null, $adwords['dev_token'], $adwords['useragent'], null, null, $credentials);

            $handler = $user->GetOAuth2Handler();
            $oauth2Info = $handler->RefreshAccessToken($user->GetOAuth2Info());
            $user->SetOAuth2Info($oauth2Info);

Using this code here I would expect that the access token would get refreshed.  If I try to make any call after it however I get 

{\n \"error\" : \"unauthorized_client\"\n}

Thoughts?

Yin Niu

unread,
Dec 22, 2015, 3:39:06 PM12/22/15
to AdWords API Forum
Hi James, 

This error means you are using a different client ID than the one that the refresh token was generated with.


Thanks,
Yin, AdWords API Team. 

James Andrews

unread,
Dec 22, 2015, 4:10:36 PM12/22/15
to adwordsapi...@google.com, AdWords API Forum
Doh!  Thanks Yin.  That’s what I get for copying code from another Google App.   

Thanks
James  


--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "AdWords API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-api/d-PDntg9BtI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-api...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/cc9c9ac7-1c29-43be-ad25-63a871dcfebb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages