Skip to content
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

I am not getting user's Birthday #1254

Closed
RNvivekvision opened this issue Mar 8, 2024 · 2 comments
Closed

I am not getting user's Birthday #1254

RNvivekvision opened this issue Mar 8, 2024 · 2 comments

Comments

@RNvivekvision
Copy link

RNvivekvision commented Mar 8, 2024

import React, { useEffect, useState } from 'react';
import { Image, StyleSheet, Text, View } from 'react-native';
import auth from '@react-native-firebase/auth';
import { GoogleSignin } from '@react-native-google-signin/google-signin';
import { RNButton, RNLoader } from './Common';
import { AccessToken, LoginManager } from 'react-native-fbsdk-next';

const webClientId = webClientId;
const iosClientId = iosClientId;

const App = () => {
const [State, setState] = useState({
isLoading: false,
User: null,
});

useEffect(() => {
init();
}, []);

const init = async () => {
setState(p => ({ ...p, isLoading: true }));
GoogleSignin.configure({
scopes: [
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/user.birthday.read',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/drive.readonly',
],
webClientId: webClientId,
offlineAccess: false,
iosClientId: iosClientId,
});
setState(p => ({ ...p, isLoading: false }));
};

const onGooglePress = async () => {
setState(p => ({ ...p, isLoading: true }));
try {
// Check if your device supports Google Play
await GoogleSignin.hasPlayServices();
const signin = await GoogleSignin.signIn();
const credential = auth.GoogleAuthProvider.credential(signin.idToken);
const google = await auth().signInWithCredential(credential);
console.log(
'onGooglePress -> ',
JSON.stringify({ google, signin, credential }, null, 2),
);
setState(p => ({ ...p, User: google }));
} catch (e) {
console.error('Error onGooglePress -> ', e);
} finally {
setState(p => ({ ...p, isLoading: false }));
}
};

const onLogout = async () => {
setState(p => ({ ...p, isLoading: true }));
try {
await auth().signOut();
setState(p => ({ ...p, User: null }));
} catch (e) {
console.error('Error onLogout -> ', e);
} finally {
setState(p => ({ ...p, isLoading: false }));
}
};

return (


{State.User ? (
<>
<Image
source={{ uri: State.User?.user?.photoURL }}
resizeMode={'cover'}
style={styles.image}
/>
<Text
style={
styles.name
}>{Hello, ${State.User?.user?.displayName}}
{Email: ${State.User?.user?.email}}
<Text
style={
styles.name
}>{Birthday: ${State.User?.user?.displayName}}
<RNButton title={'Logout'} onPress={onLogout} />
</>
) : (
<RNButton title={'Sign in with Google'} onPress={onGooglePress} />
)}

);
};

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
justifyContent: 'center',
alignItems: 'center',
},
name: {
fontSize: 20,
fontWeight: 'bold',
color: '#000',
},
image: {
width: 200,
height: 200,
borderRadius: 100,
},
});

export default App;

Repository with code that reproduces the issue

  • You must provide a minimal and easy-to-run reproduction of your issue - how to create a minimal reproduction?. We're a small team of maintainers and do not have time to try reproduce bugs ourselves.

  • Please try to reproduce the bugs on the provided example app. Either provide a link to the repo that reproduces the bug or provide your version of the index.js file that reproduces the issue and that we can easily use.

  • Explain the steps we need to take to reproduce the issue.

  • Include a gif if you think it may help.

  • If you're asking for help, please make it easy for us to help you!

Expected Behavior

Actual Behavior

{
"google": {
"additionalUserInfo": {
"profile": {
"at_hash": "XliPQTCq8muo_U-fUggVOw",
"exp": 1709883711,
"azp": "871448389881-qkfdrpelbjps7b1af1jljh4dnk8k5j6i.apps.googleusercontent.com",
"nonce": "76kKsT5sEeF_GtVNqPWTcQwNzLETfDPa-Leb4flvEUQ",
"picture": "https://lh3.googleusercontent.com/a/ACg8ocKayjEsrqPl1scTvPkPrnBlzJj3Y4NcqZmkZDtPT875=s96-c",
"name": "user user",
"email_verified": true,
"aud": "871448389881-dtndb5nq7b3ivl0n1qjg134iu61eh0jd.apps.googleusercontent.com",
"family_name": "user",
"locale": "en-GB",
"given_name": "user",
"iss": "https://accounts.google.com",
"sub": "103352901751644267865",
"iat": 1709880111,
"email": "user@gmail.com"
},
"username": null,
"providerId": "google.com",
"isNewUser": false
},
"user": {
"displayName": "user user",
"multiFactor": {
"enrolledFactors": []
},
"isAnonymous": false,
"emailVerified": true,
"providerData": [
{
"email": "user@gmail.com",
"providerId": "google.com",
"uid": "103352902741644267865",
"photoURL": "https://lh3.googleusercontent.com/a/ACg8ocKayjEsrqPl1scTvPkPrnBlzJj3Y4NcqZmkZDtPT875=s96-c",
"displayName": "user user"
}
],
"uid": "y51iamG5csTXESi0vq2YhoYlvbX2",
"email": "user@gmail.com",
"refreshToken": "AMf-vBwELeXNMgWO-SGVzuydSDy2oUuXyPDqI9lAiRdA6p94ItGiCIemgzuauBmWsjYib_MJ161fBwPn-fRzsSkSoxYB0IDY8pYNzh4U-YQfC50TPe3PcoH9Dq6YOm-945Oa0eJDeHmCfLJKyiLIROSZGo-7wV8GIuhGfbGRQC9MH7j165aqDPKc8xtTU22u2rr020SAtPHfwsXDtoEQ39w03USBk-ZmjYwui3meVhfW3LmckJ8bw5TXc-Tk1gsVGmOE3Yoh7gCs42KeZmrpi6BYa5Uhs5Kd0XDyXT94biWgK_fq4z2Xu2DbsRyOWpSJpZwQ0C5ta4ulkZZxDiwvuVytkpoqXQ3Qe3VV5L9fIXo8jqxSHF-iePExMpzux_HGYGGANXnmEE0sSIR9KXe1HiZrqHaDS-PE_ayp8nqmtopap1kACjc1g0Tuzx4MOVX7iK4pwUstPyKF",
"tenantId": null,
"phoneNumber": null,
"photoURL": "https://lh3.googleusercontent.com/a/ACg8ocKayjEsrqPl1scTvPkPrnBlzJj3Y4NcqZmkZDtPT875=s96-c",
"metadata": {
"creationTime": 1709805684941,
"lastSignInTime": 1709880112746
},
"providerId": "firebase"
}
},
"signin": {
"idToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjA4YmY1YzM3NzJkZDRlN2E3MjdhMTAxYmY1MjBmNjU3NWNhYzMyNmYiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiI4NzE0NDgzODk4ODEtcWtmZHJwZWxianBzN2IxYWYxamx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-W4jQ_YLoujnAvdUuaYX5PQphQFAIfKxzi-UO4DawY8K7g",
"scopes": [
"https://www.googleapis.com/auth/user.birthday.read",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"
],
"user": {
"photo": "https://lh3.googleusercontent.com/a/ACg8ocKayjEsrqPl1scTvPkPrnBlzJj3Y4NcqZmkZDtPT875=s120",
"givenName": "user",
"familyName": "user",
"name": "user user",
"email": "user@gmail.com",
"id": "103352901751644267865"
}
},
"credential": {
"token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjA4YmY1YzM3NzJkZDRlN2E3MjdhMTAxYmY1MjBmNjU3NWNhYzMyNmYiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiI4NzE0NDgzODk4ODEtcWtmZHJwZWxianBzN2IxYWYxamxqaDRkbms4azVqNmkuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiI4NzE0NDgzODk4ODEtZHRuZGI1bnE3YjNpdmwwbjFxamcxMzRpdTYxZWgwamQuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMDMzNTI5MDE3NTE2NDQyNjc4NjUiLCJlbWFpbCI6InZpdmVrLnZpc2lvbjIwMjRAZ21haWwuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF0X2hhc2giOiJYbGlQUVRDcThtdW9fVS1mVWdnVk93Iiwibm9uY2UiOiI3NmtLc1Q1c0VlRl9HdFZOcVBXVGNRd056TEVUZkRQYS1MZWI0Zmx2RVVRIiwibmFtZSI6IlZpdmVrIEdob2RhZHJhIiwicGljdHVyZSI6Imh0dHBzOi8vbGgzLmdvb2dsZXVzZXJjb250ZW50LmNvbS9hL0FDZzhvY0theWpFc3JxUGwxc2NUdlBrUHJuQmx6SmozWTROY3FabWtaRHRQVDg3NT1zOTYtYyIsImdpdmVuX25hbWUiOiJWaXZlayIsImZhbWlseV9uYW1lIjoiR2hvZGFkcmEiLCJsb2NhbGUiOiJlbi1HQiIsImlhdCI6MTcwOTg4MDExMSwiZXhwIjoxNzA5ODgzNzExfQ.vBiqLcZeCY_fpV2b71BK7wlFXJfIQGUNE8yjmxD6WuvOKCpY9wlOaUnoC74dMxYCegRQC-PUnDPGTy-fzfMcP7ptbZoP3a0yZQ7mhtYbj2ljBTmkTo2sTvH67BUVHtp4rUbww_aoAolNt1WcGG3ml_FK0H0C0sOu-wsAhWLt9OvrmN7TieQqMT6kmq2oaFnv737dqz95E8ITBggJSgJO3rq_ZP8ugcdxO_S0sWIwkhN3G5bMorCi3mtrFlzqetbuAUZNCzrrMbu8OQxGz2sSkFXVhJRaIfraKbCYr8P5DhVcBHIwXZI7D5I4WKNV-Gsl1oljTwVKiCQHb5J-BotsJA",
"providerId": "google.com"
}
}

Environment

Please provide

  • react-native version
  • @react-native-google-signin/google-signin version
  • your Podfile, output of running pod install and cocoapods version (if applicable)
  • version of Android, gradle, android plugin for gradle, play-services-auth and version of the Google Play Services app on your phone (if applicable)
  • version of iOS (if applicable)

"@react-native-firebase/app": "^19.0.1",
"@react-native-firebase/auth": "^19.0.1",
"@react-native-google-signin/google-signin": "^11.0.0",
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0",
"react": "18.2.0",
"react-native": "0.73.5",
"react-native-fbsdk-next": "^12.1.4"

System:
OS: macOS 14.3.1
CPU: (16) x64 Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
Memory: 51.40 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.11.1
path: /usr/local/bin/node
Yarn:
version: 1.22.21
path: /usr/local/bin/yarn
npm:
version: 10.2.4
path: /usr/local/bin/npm
Watchman:
version: 2024.01.22.00
path: /usr/local/bin/watchman
Managers:
CocoaPods:
version: 1.14.3
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.2
- iOS 17.2
- macOS 14.2
- tvOS 17.2
- visionOS 1.0
- watchOS 10.2
Android SDK: Not Found
IDEs:
Android Studio: 2023.2 AI-232.10227.8.2321.11479570
Xcode:
version: 15.2/15C500b
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.10
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.73.5
wanted: 0.73.5
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false

@vonovak
Copy link
Member

vonovak commented Mar 17, 2024

Hello and thanks for asking,
you need to query Google's people api to get additional information: https://developers.google.com/people/api/rest/v1/people/get

Thank you 🙂

@vonovak vonovak closed this as completed Mar 17, 2024
@RNvivekvision
Copy link
Author

@vonovak Thank you very much for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants