Hi, I am having trouble restoring my authToken when I call
mAccountManager.blockingGetAuthToken(Auth.getAccount(), Auth.AUTH_TOKEN_TYPE, true)
I get a null string back, which makes me look into my AbstractAccountAuthenticator class, in particular getAuth (). Here is what he does:
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException { final AccountManager am = AccountManager.get(mContext); String authToken = am.peekAuthToken(account, authTokenType); String uid = am.getUserData(account, AccountManager.KEY_CALLER_UID); // return bundle with authToken if (!TextUtils.isEmpty(authToken)) { final Bundle result = new Bundle(); result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type); result.putString(AccountManager.KEY_AUTHTOKEN, authToken); result.putString(AccountManager.KEY_CALLER_UID, uid); return result; } return null; }
PeekAuthToken returns zero, however I get the correct uid from getUserData, which makes me think that I am adding the account correctly. This is how I installed authToken:
mAccountManager.addAccountExplicitly(account, accountPassword, extraData); //The addAccount is working, and I can obtain the extraData in getAuth mAccountManager.setAuthToken(account, Auth.AUTH_TOKEN_TYPE, authtoken); //I assume this is where the authToken is to be cached…but I can't retrieve it… //The token does exist at this point
Any suggestions?
source share