Closed JokerMM closed 7 years ago
Hi @JokerMM
We have an example of getting refresh token here. Could you please have a look at that example?
Best, Knack
Hello @JokerMM ,
Instead of approval_prompt=force you might need to use prompt=consent for users to forcefully ask for permission again and to get the refresh token from google adwords once user gave permission for your app.
Hope this helps.
Thanks,
Thanks @fiboknacky @chiragvels the answer of @chiragvels is what i need, i manage to get the refresh token with it i added to the $config before the uri
Hi @JokerMM
Looks like you get an answer already, so I'll close this issue.
Best, Knack
thanks @fiboknacky
Hi @JokerMM would you care to share the bit you changed? I also need to ask for another consent if I cannot manage to find the user. Would really appreciate that!
Hi, I'm gettting the same issue unable to get the refresh token.
$oauth2 = new OAuth2( [ 'authorizationUri' => self::AUTHORIZATION_URI, 'redirectUri' => self::REDIRECT_URI, 'tokenCredentialUri' => CredentialsLoader::TOKEN_CREDENTIAL_URI, 'clientId' => $clientId, 'clientSecret' => $clientSecret, 'scope' => $scopes ] );
$oauth2->buildFullAuthorizationUri();
When i use $authToken = $oauth2->fetchAuthToken(); this function i'm getting this error "Missing authorization code".
I'm also tried the @chiragvels solutions but not works.
How can i get the refresh token. please let me know
Thanks in advance
Are you sure you've pasted the authorization code in this line correctly?
@fiboknacky No, i don't have paste the code in this line. can you please let me know from where to i get this code
Have you run that example line by line and follow the instructions, especially this one closely? If so, could you please explain more in detail what you did?
@fiboknacky Yes, I have run the exmaple code but getting errors on this function fgets($stdin) so i have adjust the code like this.
Please check my code and please let me know what is missing
const ADWORDS_API_SCOPE = 'https://www.googleapis.com/auth/adwords';
const AD_MANAGER_API_SCOPE = 'https://www.googleapis.com/auth/dfp';
const AUTHORIZATION_URI = 'https://accounts.google.com/o/oauth2/v2/auth';
const REDIRECT_URI = 'https://app.addowntime.com/index';
const PROMPT = 'consent';
$PRODUCTS = [ ['AdWords API', self::ADWORDS_API_SCOPE], ['Ad Manager API', self::AD_MANAGER_API_SCOPE], ['AdWords API and Ad Manager API', self::ADWORDS_API_SCOPE . ' ' . self::AD_MANAGER_API_SCOPE] ]; $clientId = 'client_ids'; $clientSecret = 'secret'; $scopes = $PRODUCTS[0][1]; $oauth2 = new OAuth2( [ 'authorizationUri' => self::AUTHORIZATION_URI, 'redirectUri' => self::REDIRECT_URI, 'tokenCredentialUri' => CredentialsLoader::TOKEN_CREDENTIAL_URI, 'clientId' => $clientId, 'clientSecret' => $clientSecret, 'scope' => $scopes, 'prompt' => SELF::PROMPT ] );
printf(
"Log into the Google account you use for %s and visit the following"
. " URL:\n%s\n\n",
$PRODUCTS[0][1],
$oauth2->buildFullAuthorizationUri()
);
echo "<pre>"; print_r($oauth2); die;
And Getting this response :
Did you open the browser and open the URL and copy and paste the authorization code?
@fiboknacky Yes, I have tried to copy and paste the url in browser but getting 400 error. please check the screenshot :
Could you just run the code example without modifying any parts in it? If you want to get a refresh token, you should be able to run it without modifying anything in the file.
Hi all I want to get the refresh token from google adwords to use it in refreshing my access token but i receive the access token like this :
without the refresh token
after searching in the internet i found that we need to set access_type to offline and the ApprovalPrompt to force
the access_type i set it but the ApprovalPrompt not found it
this is my call
how i can get the refresh token ????
thanks for your help