-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[google_sign_in_web] Migrate from Google Sign-In JavaScript Platform Library to Google Identity Services #88084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[google_sign_in_web] Migrate from Google Sign-In JavaScript Platform Library to Google Identity Services #88084
Comments
\cc @ditman |
See also #82980 |
Thanks for reporting! I'll take a look at this ASAP; apologies for the nagging emails, I wasn't aware that this migration was going to happen or that we'd send out emails to eeeevery user of the plugin :) Speaking of the email, here's the full text we all received (included for SEO purposes on this issue :P)
Luckily we have until 2023 to get this done ;P Since google_sign_in is federated, we can start a new package for web that uses the new SDK. People will be able to test the new plugin while it's being developed, and once the new plugin is ready and tested, we can just change the endorsement to the new one. I am not sure if we want to use this opportunity to rewrite the core plugin (a completely new platform interface, etc...). Any ideas @jmagman @blasten @stuartmorgan ? |
Is this using the new two-phase flow like the latest iOS SDK? If so, then we should seriously consider a set of breaking changes to all the interfaces across platforms to pick up that model. (We're waiting a bit to see what happens with the feedback that the new iOS SDK has received though in case anything changes as a result.) |
I'm going to try and follow-up with somebody in the Google Identity Services team for a little bit more insight into this matter, and to see if they have any preference/suggestion in the future direction of the plugin API. |
@ditman looking forward to this update, got a rough eta? |
Any update regarding Flutter Web, because the Google One-Tap Sign In package works only for Android. |
@cybex-dev not yet, but I brought this up again to the team so it gets prioritized. @Zujaj that package is developed by a third party and we don't support it. Find its repository here. |
any news about this issue @ditman ? |
No news, I'd personally would like to wrap this up by Q3 2022 so there's one Q for user testing/emergency fixes, and then we can release this at the end of Q4 2022 (right before the migration must happen) |
See some interesting comments in the related ticket above:
We'll need a new JS-interop layer to go with the plugin. Also, since this seems to only affect web, we'll try to implement the already existing plugin API with the new JS API. Docs. It seems that a migration to the new API with |
/cc @kevmoo any chance we could use |
@ditman – perhaps? Tha browser auth code there is pretty old. I've done some cleanup there, but it's pretty old. In general, fewer Dart implementations of this logic would be better! |
Immediate next steps to mitigate:
We'll do a small modification to the google_sign_in plugin suggested by @brdaugherty today so new applications can continue using the plugin after April 30th 2022. |
This has been published as |
@ramonvermeulen That is correct. This happened because the former SDK did authentication+authorization in one step, but now they're two separated clients. On signInSilently, only authentication happens, so if the plugin gave you an "authenticated but not authorized" user, all your API requests would start failing. Only when the user is fully authenticated and authorized (after signIn), you get a signed in notification.
You cannot
(Your code is probably already doing 1 and 2 above)
That is not going to be possible moving forward, since the new SDK is separating authentication (user ID) from authorization (user permissions). However, if the user has never signed out of your application (or their tokens have expired), their sign-in will be almost automatic (the popup will show up, but will close automatically without users having to do anything extra).
Don't worry about the last line. That's a trick that the new SDK is attempting to do to be "less breaking" with the users of those libraries. In fact, you should not need any script tag for google authentication to work. Check our super-simple example app. The biggest issue that you might encounter is that API requests from your app might start failing, and users need to re-authorize access to the |
@ditman Thanks a lot for your clarification! With this information I think I need to redesign the flow in the application a little bit to make this work. In my case
I can always use In my opinion it feels really unnatural that after Out of an implementation perspective I totally get it, they are two different clients one for authentication (GIS one-tap part) and one for authorization (old style pop-up). But for my application it feels more like a step back rather than a step forward. P.s. I will clone and test the example app to hopefully get a bit wiser |
@ramonvermeulen in your case, maybe it's simpler to just stop doing About The code of the new plugin does what it does to maximize the compatibility with the previous code, without you having to change much about the sign-in flow (for more details, pls look at the full README!)
I agree. This plugin is just another user of the new GIS SDK and had very little input on its design. In fact, the way this unfolded has us thinking about the future of the Google Sign In plugin(s) as a whole. I can explain why this is moving to a "two step" process, though! In the near future, idTokens may come straight from the user's web browser rather than Google; for example see FedCM, and FIDO2. In those cases, the Authentication is handled by the browser, locally, but the Authorization process would still need to call the remote service for permissions. Anyway, thanks for giving this a shot, I hope you manage to work around the quirks of the new SDKs! |
@ditman Thanks for the explanation! I eventually got it all working in the application, had to dive a bit into how to persist state with bloc using hydrated bloc and make some structural changes to the application. I save the authHeaders in state now, and log the user out if I get a 403 back from one of the google APIs. The accessToken has a lifetime of 1 hour, so after 1 hour the user has to manually sign in again. I haven't seen a mechanism to refresh the accessToken yet (can't find a refreshToken in I haven't heard of the FedCM and FIDO2 concepts before. Thanks for referring to it, makes more sense now why google is separating authentication and authorization to different APIs. |
@ramonvermeulen This is not possible from the client-side anymore, if you want to extend a users' session, they need to re-authorize the scopes. The only way that I'm aware of that you get a renew token and all that jazz is if when you use the "Authorization Code" model, which then you use from your server-side to do requests to Google on your users' behalf, behind the scenes. Then your users access your backend (and not Google's) where you're supposed to have all the data they need.
I think a blog post about this, if you have the energy to write it, would be very beneficial to the community. I can't handle all the integrations with all the possible state management solutions, but we can have links to blog posts describing solutions for the most common architectures! |
The PR has been reviewed and labeled as |
Reopening this until we update the core plugin to use the new version! The new version of the web package (
|
Thanks for the information, also nice job on the Migrating to v0.11 section in the readme, explains everything really well in my opinion. I see, in my case we don't have our own server-side "back-end" for this app. It's just a client calling Google API's for authentication / authorization, and then fetching search results from the Google Cloud Search API (which is basically the back-end). But I don't think it will be that big of a problem that an user has to re-authorize after 1 hour of inactivity, was just wondering if there were other options. Unfortunately I'm quite packed with work at the moment, so I don't have a lot of time to write a blog post. However, for people reading this and facing the same issues and are already using flutter_bloc as state management solution within their application. Be sure to take a look at hydrated_bloc which is the library I used to persist the bloc state, for instance you can store the authHeaders persistently so a user can stay "signed-in" with the required scopes for up to one hour. |
@ramonvermeulen yes, this is the case of many people too, you're not alone :)
I think users have to re-authorize after 1 hour (even if they're being very busy with your app!)
Again, thanks for giving this a test, checking the documentation and everything! Please, feel no pressure about the blog post at all! It's possible that others will fill the gaps. IMO people finding this issue and knowing that their migration "is possible" is quite a good start! |
Hi! @ditman I call Here's my piece of code Future<String> signInWithGoogleIdToken() async {
GoogleSignInAccount? account;
try {
account = await googleSignIn.signIn();
} catch (e) {
_catchSignInError(e);
}
final authentication = await account?.authentication;
return authentication?.idToken ?? '';
} I've read the previous conversation here and think that I will appreciate it if you can give me some advice on what could happen wrong 🙏 |
@TimYusR, @scrfrk, @NickelGit, @Silipok, @ruslanislan, @JavasquirtDeveloper, @tuanvumaihuynh you're correct. Since If you need the Here's the relevant information about your use case: (Since we have received a bunch of feedback regarding this, I'm going to report the lack of an |
So I need to call @ditman Thanks!
|
It is, however it was required to make the new SDK behave similarly to the old one to ease the migration of everybody! |
A few comments after testing: 1/ using googleSignIn.signIn() works well with firebase auth in the cloud but will break firebase auth emulator since it expects idToken. Error is the following :
2/ and when using Future googleLogin() async {
try {
await googleSignIn.signInSilently();
final googleUser = await googleSignIn.signIn();
if (googleUser == null) return;
final googleAuth = await googleUser.authentication;
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
await FirebaseAuth.instance.signInWithCredential(credential);
} catch (e) {
debugPrint(e.toString());
}
} It works well on a chrome session that already knows my google account, however it fails in an incognito window. |
@pldelattre It doesn't work, because the retry needs to be done by signInSilently. You should probably refresh the incognito window after sign-in, to let the signInSilently process to work? |
If you look at my googleLogin() function in the message above which is the function I call with the button, you can see that the first line is calling signInSilently and this is why I expected a retry on the button to work. Unfortunately, it does not. |
Please, check the JS Console of the browser (in development mode) for logging, it'll let you know if the OneTap UX decided to not show up for any reason. There's a few reasons why the "One Tap UX" may not show, it's smart. Please, use signInSilently as advised: when you build your pages, and not as part as your "signIn" button implementation. There's also an internal bug that I'm trying to get solved to make this much simpler for everybody; as mentioned here. |
With the current solution it feels a bit strange, since google silent login will always be triggered on my LoginPage (using it as stated in the example within the |
@c-seeger yes, you're right. I guess your Login page is similar to a "logo tower" with a bunch of login options. In that case, GSI recommends this: This is a missing feature of the current (There's also the problem that users authenticating there would still not authorize scopes however!) |
Hello all who must have an I'm currently implementing the "Google Sign In Button" flow for the web. Please, follow the progress in the corresponding places:
The PR adds the "Google Sign In Button" as a Flutter for Web Widget, so Web apps can use that instead of the programmatic It also adds a Also also: updates the (PS: I think we should stop updating this issue. Let's continue the conversation in the issues/PRs that are being actively worked on, or on new ones for anything new that might show up. Thanks for reading!) |
hey @ramonvermeulen how did you fix your issue with |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Uh oh!
There was an error while loading. Please reload this page.
Original issue below:
Internal: b/233812803
Internal: b/259309242
Google Sign-In JavaScript Platform Library used by the google_sign_in web plugin will be discontinued on March 31, 2023.
It is being replaced by Google Identity Services
https://github.com/flutter/plugins/blob/b548ae18646d1725a8e1f004c26bf42e4d362aa8/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart#L24
See also
The text was updated successfully, but these errors were encountered: