Home » Android » android – How to revoke the permission that my app get from user's google gmail AccountManager.getAuthToken(

android – How to revoke the permission that my app get from user's google gmail AccountManager.getAuthToken(

Posted by: admin June 15, 2020 Leave a comment


Created a test app using Eclipse to get the authToken from one of my google e-mail accounts on my device.

Executing this prompted me with the allow access dialog where i press allow access:

accountManager.getAuthToken(account,"oauth2:https://www.googleapis.com/auth/userinfo.profile", false, new GetAuthTokenCallback(), null);

I wanted to create a chooser dialog that works from API8 and up where the user can choose
what google account he allow me to access. To do this i have to revoke the permission to see the screen again.

should i see my test app on this page or not?
Authorized Access to your Google Account

I have search for a way to revoke the permission and non is working..
Only thing working is to create a new app project.

Using the Google Play service GCM and this is working ok

How to&Answers:

Regarding the “Authorized Access to your Google Account” page, you will not see your app there as this permission is a device local permission stored in a database on the phone.

It does not seem like it is possible to revoke this permission in an easy way. I’ve been able to find a couple of ways to be able to trigger the dialog again, but none are ideal. In some of these solutions it’s not the exact same dialog that is shown, but it might be close enough for testing purposes depending on what you want to do:

Internally the getAuthToken method keeps track of if access has been granted or not using the UID of the application. So if you are able to somehow force Android to give your app a new UID or to force it to clear the database of given grants the dialog should be shown again. Here are some solutions that others say work for them but that doesn’t work for me (maybe it depends on which phone you use?):

As a side note as revoke permissions to access google auth tokens mention there are internal Android methods for revoking access, but these are not accessible via the public API.


There are two cases that you must consider:

  1. Server Side Authorization
  2. Android Account Manager (Device side) Authorization

Case 1:
Server Side revocation for Google Accounts can be done at: https://accounts.google.com/IssuedAuthSubTokens

You just have to login with the corresponding google account and choose to revoke the App/Website

Case 2:
If on your android device you are presented with a screen saying something like: “Application wants to access your Google Account….Allow/Deny? ” then this is an Account Manager type authorization where you need to modify the sqlite3 database on your phone in order to revoke the application (not as trivial as the Case 1 and this requires root accessed to your phone):

i. First copy off the database and journal file (accounts.db and accounts.db-journal) to another location (eg: on your SDcard or to a computer). The database files can be found in this directory on your android device:


ii. You now need a sqlite3 editor. I used Sqlite Debugger from the Google Play Store. Alternatively you can use an sqlite3 binaries from http://www.sqlite.org/download.html and do this on a Computer.

iii. You know need to use the editor to remove certain entries in the “extras” table of the accounts.db database. You might want to take a quick tutorial on sqlite commands but here are some examples and “Sqlite Debugger” makes this a easy learn:

First open the accounts.db file in the editor

To list all rows in table “extras” you could use the following command:

SELECT * from extras

A better idea would be to only list rows in table “extras” which correspond to the application which you would like to revoke. For example if “com.someapp” is the name of your App you could use the following command:

SELECT * from extras WHERE key like '%com.someapp%'

You should get some output similar to this:


Make a note of the id numbers you want to delete from the above output (i.e. the rows corresponding to the App you want to revoke) and then use the following commands to delete those rows:

DELETE from extras where _id = 10
DELETE from extras where _id = 11

Copy back the database and journal file to its original location. Make sure you set the permissions and ownership back to the original. read/write for owner and group only and owner and group owners are both “system”. This operation will require root access!

Restart your device and you should have revoked the permission for the App. You could test this by asking the app to request Authorization again. If you are presented with the screen asking you to Authorize the app (“Application wants to access your Google Account….Allow/Deny?) then you have successfully revoked the app.


  1. https://groups.google.com/forum/#!topic/android-developers/3lQb83jeyE8
  2. https://github.com/jberkel/sms-backup-plus/issues/369


Uninstalling and restarting the device was the answer.
I had to give it some time before restarting.

Update..Have to say this only works sometimes.