[Android] refresh expired token "I don't know how to refresh token on Android"
Greetings everyone ,
I happen to face an issue with android google auth , it's working all fine , I am able to sign in and get idtoken which I store in localstorage and sent it in the network . However when this idtoken expires , I call the GoogleAuth.refresh() which doesn't seem to work on android i'm getting this error message "I don't know how to refresh token on Android" . Albeit , it's working perfectly fine in the web where i'm able to get the refreshed token .
How are you guys able to refresh your tokens in android ? any advice ?
ps : I didn't test this in IOS yet .
I would highly appreciate your help :)
Hello 👋 You're facing this problem because refresh isn't implemented for android. But it is implemented for web. What I suggest is for you to look into The silentSignin() method of Google Android Library and you can perhaps try implementing the refresh method yourself. That's what I'm currently experimenting with. If it seems to work, I'll try opening a pull request 🤷.
I have a very similar use case where I need to refresh the access_token so I can pass it to gapi.client. Similar to #175
Hello @Translucent504 , I hope you're doing fine :) .
Have you come up with a solution yet ?
I really need it badly !! my whole project is now on hold because of that problem :/ .
thanks in advance .
@kamalessafi I overrided the refresh method, it looked something like this gist you'll probably need to clean it up a bit but it'll work in the current state by returning a refreshed access token in the auth object whenever you call the refresh method.
@Translucent504 thank you very much ^^ . I will try it and come back to you .
Thanks again
Hello @Translucent504 I hope you're having a wonderful day ,
As for what you have posted as a solution didn't work for me :/ . I'm getting this error " com.google.android.gms.common.api.ApiException: 4: 4: " whenever I'm calling this method Task<GoogleSignInAccount> task = googleSignInClient.silentSignIn();
Any further help would be much appreciated ^^ .
@kamalessafi I overrided the refresh method, it looked something like this gist you'll probably need to clean it up a bit but it'll work in the current state by returning a refreshed access token in the auth object whenever you call the refresh method.
wow, thanks, the refresh method worked for me
ANy help here. I see a lot of people who try to find a solution to this.
Hello @Translucent504 I hope you're having a wonderful day ,
As for what you have posted as a solution didn't work for me :/ . I'm getting this error " com.google.android.gms.common.api.ApiException: 4: 4: " whenever I'm calling this method Task task = googleSignInClient.silentSignIn();
Any further help would be much appreciated ^^ .
I'm getting the same issue. Can you tell me how to resolve this?