-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[google_sign_in] adds option to re-authenticate on google silent sign in #4251
[google_sign_in] adds option to re-authenticate on google silent sign in #4251
Conversation
Thanks for the submission! @ditman Are you familiar with this portion of the API in order to review? |
@stuartmorgan not with the native implementations. I'm almost sure that this would do nothing special on the web, since @ThetaSinner have you verified this change has the desired behavior in the other platforms? I can't find any information about reauthentication in web (I think it's handled automatically by the JS SDK) or iOS. (Overall, this doesn't seem dangerous to merge, I'm wondering if more needs to be done across all platforms to achieve the same functionality) |
Hi @ditman, I haven't tested iOS because I don't have a MacBook or iOS device (or any emulation set up) but I'm happy to give web a try to see how it behaves. I don't have access to my development environment today or tomorrow but I will take a look Sunday/Monday |
Thanks @ThetaSinner! As I said, in web I'm not sure that calling signInSilently multiple times will cause the same effect as in android, but that's a gap that can be filled later. We just need to confirm it, so we can document the difference across platforms. |
Looks like you're right about the web behaviour, the existing login is used to build the response to signInSilently. The underlying JavaScript library does not discuss ID tokens (that I have seen!). The signIn method it provides is interactive. It doesn't look like working quietly with ID tokens on web will work without a change to the google-api-javascript-client library. I don't need it so I'm happy with documented differences. Would you like me to find somewhere for that to go and add it to this PR? |
The web version is going to need a bunch of rewriting soonish, that might change things. In the meantime, let's do this. I think the web version re-authenticates automatically, so as long as one always requests the current identity from the JS code, the token will always be valid (at least, that's my operating assumption :P) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Let me find somebody from the iOS team to verify that this won't hurt there!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on iOS
Thanks for the super-late review @cyanglaz !! |
Hey @ThetaSinner, I wanted fresh idToken whenever i sign in. So I used this signInSilently method with reAuthenticate param as true. But I keep on getting the same idToken even after using this. |
Hi @Bharathh-Raj, This is the code I use await _googleSignIn.signInSilently(
reAuthenticate: true, suppressErrors: false); I believe the API will not give you a new ID token unless your current ID token is about to expire (less than 5 minutes remaining?) OR your ID token has expired and your REFRESH token is still valid. You can check this by grabbing your own ID token and decoding it locally. If this isn't the answer to your problem then feel free to tag me in a new issue on your project and I'll see if I can help out |
So the OAuth API itself won't give us new idtoken unless it is about to/did expire? Is there any way to force the api to respond with new id token whenever I request? I'm using a service which have just 60 seconds window time to validate. |
Adds an optional paramter to the signInSilently method which allows the application using the plugin to decide whether re-authentication should be attempted.
Fixes #88556
Pre-launch Checklist
dart format
.)[shared_preferences]
///
).