My question is here (How to check if the user is logged in using "Google Sign In" (OAuth 2.0)), but the related package is deprecated (https://developers.google.com/identity/login/network /personnel).
I use Google One Tap in my project. How do I know if a user is signed in to their Google Account using Google One Tap.
P粉8055354342024-03-28 11:00:03
I asked Google Bard and I think it gives a good answer.
There are several ways to check if a user is logged in to Google.
Here's an example of how to check if a user is logged in using the Google Sign In API:
const googleSignIn = require('google-signin'); const auth2 = googleSignIn.build(); const isSignedIn = await auth2.isSignedIn(); if (isSignedIn) { // The user is logged in. const user = await auth2.currentUser(); // Do something with the user's information. } else { // The user is not logged in. }
Use Google One-Click Package:
const googleOneTap = require('google-one-tap'); const auth2 = googleOneTap.build(); const isSignedIn = await auth2.isSignedIn(); if (isSignedIn) { // The user is logged in. const user = await auth2.currentUser(); // Do something with the user's information. } else { // The user is not logged in. }
In addition, you can also access other user information through these two packages. If you need a different solution, you can use Google Bard.