We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I get the refresh_token via curl after I revoke/remove the apps access from account(everytime).
curl
<? //Reference to dbjpanda/google-api.php(https://gist.github.com/dbjpanda/0ba3d73832b25d720398e8f1dce1359b) $client_id = 'xxx.apps.googleusercontent.com'; $client_secret = 'xxxx'; $redirect_uri = 'https://example.com/get_token.php'; $end_point = 'https://accounts.google.com/o/oauth2/v2/auth'; $token_file="my-token.json"; $authUrl = $end_point.'?'.http_build_query([ 'client_id' => $client_id, 'redirect_uri' => $redirect_uri, 'scope' => 'https://mail.google.com/', 'access_type' => 'offline', 'include_granted_scopes' => 'true', 'response_type' => 'code', ]); echo '<a href = "'.$authUrl.'">Authorize</a></br>'; if ( !file_exists($token_file) ){ if ( isset($_GET['code'])){ $code = $_GET['code']; }else{ return; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://accounts.google.com/o/oauth2/token"); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/x-www-form-urlencoded']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ 'code' => $code, 'client_id' => $client_id, 'client_secret' => $client_secret, 'redirect_uri' => $redirect_uri, 'grant_type' => 'authorization_code', ])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close ($ch); }else{ //and then to use the refresh_token to get a new access_token } var_dump($request); // There contains the refresh_token
But I cannot get the refresh_token via thephpleague/oauth2-client after I revoke/remove the apps access from account.
thephpleague/oauth2-client
$provider = new \League\OAuth2\Client\Provider\Google([ 'clientId' => 'xxx.apps.googleusercontent.com', 'clientSecret' => 'password', 'redirectUri' => 'https://example.com/get_token.php', 'scopes' => ['https://mail.google.com/'], 'access_type' => 'offline' ]); $accessToken = $provider->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]); var_dump($accessToken->getRefreshToken()); //It is null
What do I miss?
The text was updated successfully, but these errors were encountered:
Typo: access_type should be accessType in your options array, as per the README
access_type
accessType
Sorry, something went wrong.
No branches or pull requests
I get the refresh_token via
curl
after I revoke/remove the apps access from account(everytime).But I cannot get the refresh_token via
thephpleague/oauth2-client
after I revoke/remove the apps access from account.What do I miss?
The text was updated successfully, but these errors were encountered: