react-native-google-signin / google-signin

Google Sign-in for your React Native applications
https://react-native-google-signin.github.io/
MIT License
3.12k stars 877 forks source link

Accessing Google's info in scopes #1236

Closed lucaromano-intelligentia closed 4 months ago

lucaromano-intelligentia commented 5 months ago

I describe the steps to explain in a simple way.

  1. I add more scopes
  2. I call the GoogleSignin.signIn() sign-in method
  3. In the modal, I log in with the google account and grant permissions
  4. Login done
  5. The information retrieved after login is the same as when I do not add scopes.
GoogleSignin.configure({
    webClientId: "---",
    offlineAccess: true,
    scopes: [
        'https://www.googleapis.com/auth/userinfo.profile',
        'https://www.googleapis.com/auth/user.birthday.read',
        'https://www.googleapis.com/auth/user.gender.read',
        'https://www.googleapis.com/auth/user.addresses.read',
        'https://www.googleapis.com/auth/userinfo.email',
        'https://www.googleapis.com/auth/plus.login',
    ],
});
await GoogleSignin.hasPlayServices().then(async (hasPlayService) => {
    if (hasPlayService) {
        await GoogleSignin.signIn().then((userInfo) => {
            console.log(userInfo);
            setState(true);
            setUser(userInfo);
            setDisabled(false);
        }).catch((e) => {
            console.log("ERROR SIGN-IN: " + JSON.stringify(e));
            setUser(null);
            setDisabled(false);
        });
    }
}).catch((e) => {
    console.log("ERROR HAS PLAY SERVICES: " + JSON.stringify(e));
    setUser(null);
    setDisabled(false);
});
vonovak commented 4 months ago

Hello and thanks for asking, I'm not really sure what the question here is. Please feel free to open another issue and follow the template. Thank you 🙂