I am trying to make user authorization my REST service from an Android device. After the first confirmation, everything works correctly, but if I want to get a new token from GoogleAuthUtil.getToken after clearing the old token using GoogleAuthUtil.clearToken , I get com.google.android.gms.auth.UserRecoverableAuthException: NeedPermission , which leads to the application consent screen with "have access to offline access . After I granted permission, I get a new token in onActivityResult or using GoogleAuthUtil.getToken , but if I clear the token again, I still get an Exception call that calls GoogleAuthUtil.getToken
String SCOPE = Scopes.PLUS_LOGIN; ... String scope = String.format("oauth2:server:client_id:%s:api_scope:%s", CLIENT_ID, SCOPE); String token = GoogleAuthUtil.getToken(AuthorizedActivity.this, email, scope); ... //send received token to server for confirmation ... try { GoogleAuthUtil.clearToken(AuthorizedActivity.this, token); } catch (GoogleAuthException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ...
and my server:
... $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;
, and this still happens an hour after the token is cleared.
So, my question is what I am doing wrong, and why I continue to receive a consent screen after clearing the token used. Do I need a specific permit, incorrect coverage, or am I missing something else?
Sigitas
source share