The example for using reauthenticate()
in Firebase shows only how to re-authenticate a user who signed with Email and Password:
AuthCredential credential = EmailAuthProvider.getCredential("[email protected]", "password1234");
FirebaseAuth.getInstance().getCurrentUser().reauthenticate(credential);
I also know how to re-authenticate with Facebook Provider (credential = FacebookAuthProvider.getCredential(AccessToken.getCurrentAccessToken().toString())
).
Problem is there’s no equivelant method in Google API to get the current Access Token and eventually get the AuthCredential
. So what do I pass to getCredential()
in this case?
3
Answers
Considering you would have received
GoogleSignInResult
as a response to sign-in, I think you can use the following code:You can get
GoogleSignInResult
via 2 way to authenticate.i) By entering email id and password into google login screen.
ii) By selecting account from already logged in account in phone.
i have used 2nd approach to get access token and authenticate user.
for more support references links are given below.
google sign in link 1
Stackoverflow – token refresh
google auth provider documentation
server side token verification docs
if your only objective is, to get token so you can also try this github source.
//use sign in option to build api client instence.
// get authenticated
I know this is old question but I did not found complete answer to this. This is how to do it on Android.