Nick
Nick

Reputation: 6385

Google Play Services - Clear allowed accounts

When using the new Google Play Services to authenticate an account, you first use the AccountPicker to allow the user to select an account. If the user has not authenticated with your application before, a UserRecoverableAuthException will be thrown which gives you an intent to show the 'Allow Access' page. You only need to allow access one time. However, for testing purposes, I need to be see the Allow Access page every time.

So, does any know how you can clear the permissions for Google Play Services? Or some other method that will show the allow access page every time?

Upvotes: 3

Views: 808

Answers (1)

Stephen Wylie
Stephen Wylie

Reputation: 934

In your Google Account Settings, there's a way to set up application-specific passwords. Sign up for 2-step verification and then you can create them. To temporarily revoke the permission, you can remove or change the password: http://support.google.com/accounts/bin/answer.py?hl=en&answer=1070455

Otherwise, change the password to your entire Google account temporarily.

Unfortunately I don't think there's an easy programmatic way to do this. It seems like quite a serious security flaw that a user/administrator can't revoke Google Account access to an installed app. From what I can tell, Google is fetching the authentication information from a server, and if something in that operation fails, it throws the UserRecoverableAuthException. That's when you normally fire off the Intent from UserException.getIntent(), which contacts the server with a request such as:

scope:oauth2:https://www.googleapis.com/auth/drive.readonly[
    account:<your_account>@gmail.com,
    scope:oauth2:https://www.googleapis.com/auth/drive.readonly,
    extrashash:<some_number>]

Now there's no documentation I've found for instructing the server to revoke that Auth Scope requested above. It might not even be possible. However, you could try to capture the values in the Intent returned by UserException.getIntent() and use it to create a new Intent you launch whenever the user wishes to sign in with their Google account. However, the server might realize the app is already authenticated, and then send you through without the prompt.

Upvotes: 2

Related Questions