Hi,

Thanks, that clears things up a bit.

I just tried running the GetRefreshToken.php example 
<https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/Auth/GetRefreshToken.php>
 using 
my account and I was able to obtain a refresh token without issues. Could 
you modify your code so that you log the contents of *$oauth2Info*? I'd be 
curious to see what (if anything) is set on that object.

If you post the contents here, please make sure you remove any sensitive 
information first.

Thanks,
Josh, AdWords API Team

On Tuesday, March 17, 2015 at 2:45:41 PM UTC-4, jody stein wrote:
>
> Yes here is the PHP to process the code returned which used to 
> return refresh_token an now returns just the client_id and client_secret. I 
> am using the right paramenters, access_type=offline and tried 
> adding prompt=consent. 
>
> $user = new AdWordsUser();
> $user->LogAll();
> $handler = $user->GetOAuth2Handler();
> $oauth2Info = $handler->GetorRefreshAccessToken($user->GetOAuth2Info(), 
> $code, $redirectUri);
> // I also tried this version just in case which returns the same thing
> //$oauth2Info = $handler->GetAccessToken($user->GetOAuth2Info(), $code, 
> $redirectUri);
> $user->SetOAuth2Info($oauth2Info);
>
> if(isset($oauth2Info['refresh_token'])){
> $refreshtoken=$oauth2Info['refresh_token'];
> $accesstoken=$oauth2Info['access_token'];
> $timestamp = isset($oauth2Info["timestamp"]) ? $oauth2Info["timestamp"] : 
> 0;
> $expiresIn = isset($oauth2Info["expires_in"]) ? $oauth2Info["expires_in"] 
> : 0;
> //do the rest of the processing to save token
> }
>
> Does that make more sense?
>
>
> On Tuesday, March 17, 2015 at 11:02:04 AM UTC-7, Josh Radcliff (AdWords 
> API Team) wrote:
>>
>> Hi,
>>
>> I may be misunderstanding your question, but I think you're missing a 
>> step. After the user accepts the OAuth prompt, your redirect endpoint will 
>> receive an *authorization code* (the 
>> *https://domain.com/pro/login/googleredirect.php?code= 
>> <https://domain.com/pro/login/googleredirect.php?code=>4/xxx* request 
>> below), which it then must submit in order to get the *refresh token*, 
>> as illustrated in the OAuth guide 
>> <https://developers.google.com/accounts/docs/OAuth2WebServer#overview>.
>>
>> Thanks,
>> Josh, AdWords API Team
>>
>> On Monday, March 16, 2015 at 10:38:07 PM UTC-4, jody stein wrote:
>>>
>>> I am running into the same problem. I have not made any changes however 
>>> I am not able to add new users. The refresh token is no longer being 
>>> returned. 
>>>
>>> Here is the request URL I am using. 
>>>
>>>
>>> https://accounts.google.com/o/oauth2/auth?prompt=consent&response_type=code&client_id=xxxx.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fdomain.com%2Fgoogleredirect.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadwords&access_type=offline
>>>
>>> I receive the response with no error. However the refresh_token is no 
>>> longer being sent. 
>>> https://domain.com/pro/login/googleredirect.php?code=4/xxx
>>>
>>> Am I doing something wrong here? or did something change recently?
>>>
>>> Any help would be greatly appreciated!
>>>
>>>
>>>
>>>
>>> On Thursday, June 5, 2014 at 1:53:13 PM UTC-7, Mike Swan wrote:
>>>>
>>>> Hi All,
>>>>
>>>> I have scoured the group and the Internet (SO, etc.) and I can't find 
>>>> any direction.  For some reason a refresh token is not being returned 
>>>> through the API along with the access token.  
>>>>
>>>> My auth URL looks like this:
>>>>
>>>> https://accounts.google.com/o/oauth2/auth?state=10&response_type=code&client_id=xxxx.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Fdomain.com%2Fapi%2Foauth2return-Adwords.php&scope=https%3A%2F%2Fadwords.google.com%2Fapi%2Fadwords%2F&access_type=offline
>>>>
>>>> It returns this:
>>>>
>>>> http://domain.com/api/oauth2return-Adwords.php?state=10&code=xxx
>>>>
>>>> Which gets put through this script:
>>>>
>>>> $callbackUrl = "http://domain.com/api/oauth2return-Adwords.php";;
>>>>  
>>>> // Create a new user and set the oAuth settings
>>>> $user = new AdWordsUser();
>>>> $user->SetOAuth2Info(array(
>>>>     "client_id" => 'xxx.apps.googleusercontent.com',
>>>>     "client_secret" => "xxx"
>>>> ));
>>>>
>>>> $authCode = $_REQUEST['code'];
>>>>
>>>> $OAuth2Handler = $user->GetOAuth2Handler();
>>>> $user->SetOAuth2Info($OAuth2Handler->GetAccessToken($user->GetOAuth2Info(),
>>>>  
>>>> $authCode, $callbackUrl));
>>>>
>>>> Everything works fine, but this is all I am getting back:
>>>>
>>>> [oauth2Info:AdsUser:private] => Array
>>>>
>>>>         (
>>>>
>>>>             [client_id] => xxxx.apps.googleusercontent.com
>>>>
>>>>             [client_secret] => xxxxxxx
>>>>
>>>>             [access_token] => ya29.xxxxxxxxxxxxx
>>>>
>>>>             [token_type] => Bearer
>>>>
>>>>             [expires_in] => 3599
>>>>
>>>>             [timestamp] => 1401998014
>>>>
>>>>         )
>>>>
>>>> So I can pull the data I need, but I have to reauthorize every time. 
>>>>  This is using an MCC.  Is there something I am missing?  
>>>>
>>>> Thanks for your help.
>>>>
>>>> Mike
>>>>
>>>>
>>>>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/ba7eed3f-e0ef-4abb-bce5-98a14bc8ff61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to