I'am trying to make user authorization with my REST service from android device. After first confirmation everything works correctly, but if i want to get new token with GoogleAuthUtil.getToken after clearing the old token with GoogleAuthUtil.clearToken I get com.google.android.gms.auth.UserRecoverableAuthException: NeedPermission exception which leads to app consent screen with "have offline access" permission. After i grant the permission i get new token in onActivityResult or with GoogleAuthUtil.getToken, but if I clear the token again I still receive the Exception calling GoogleAuthUtil.getToken
String SCOPE = Scopes.PLUS_LOGIN;
...
String scope = String.format("oauth2:server:client_id:%s:api_scope:%s", CLIENT_ID, SCOPE);
GoogleAuthUtil.getToken(AuthorizedActivity2.this, email, scope);
...
//send received token to server for confirmation
...
try {
GoogleAuthUtil.clearToken(AuthorizedActivity2.this, code);
} catch (GoogleAuthException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
...
and my serverside:
...
$client = new Google_Client();
$client->setClientId('CLIENT_ID');
$client->setClientSecret('CLIENT_SECRET');
$client->setDeveloperKey('');
$client->authenticate('token_from_device');
return json_decode($client->getAccessToken())->access_token; // temporary
...
and it is still happening after one hour after clearing the token.
So my question is what am I doing wrong and why do i keep getting the consent screen after clearing used token. Do i need a specific permisson, wrong scope or I am missing something else?
0 comments:
Post a Comment