Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does AccountManager.invalidateAuthToken requires AccountType instead of AccountName?

When invalidating authorized tokens from AccountManager using invalidateAuthToken,

Q1: Why does the function requires the Type of the account when using the Name of the account seems to make more sense?

Q2: By giving it the Type, does invalidateAuthToken wipe out all auth tokens under that account type?

like image 256
Some Noob Student Avatar asked Nov 04 '22 08:11

Some Noob Student


1 Answers

Q1: type is not as restrictive as name, it implicitly indicates that you are dealing with a group and not an individual, IMHO.

accountType defines what type of account you are fetching in the accountManager. for example: "www.google" for google accounts. given a bundle inside a callback, you find out the accountType by using:

private class GetAuthTokenCallback implements AccountManagerCallback<Bundle> {
    public void run(AccountManagerFuture<Bundle> result) {
        try {
           bundle = result.getResult();
           String auth_token = bundle.getString(AccountManager.KEY_AUTHTOKEN);
           String auth_account_type = bundle.getString(AccountManager.KEY_ACCOUNT_TYPE);

Q2: according to the developers guide, the syntax is:

public void invalidateAuthToken (String accountType, String authToken)

accountType must NOT be null, but authToken may be null. if you omit authToken, you clear all tokens for that accountType

like image 81
tony gil Avatar answered Nov 12 '22 19:11

tony gil