How to get OAuth 2 refresh token using access token

孤街醉人 提交于 2019-11-30 16:37:35

I got the answer now i want to share to all of you because many questions are unanswered.

to get a new token first you have to invalidate the token using below code

accountManager.invalidateAuthToken("com.google", token);

after invalidating the token you require to get a new Token, below code provides a new Token

String newToken = AccountManager.get(this).getAuthToken(new Account(account, "com.google"),
                 AUTH_TOKEN_TYPE, true, null, null).getResult().getString(AccountManager.KEY_AUTHTOKEN);

now you can use your new token to authenticate and login.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!