React native 如何使用谷歌登录世博会认证会话获取用户电子邮件?
目前,我正在使用这段代码登录谷歌,但我无法获得用户电子邮件…有人知道如何做到这一点吗React native 如何使用谷歌登录世博会认证会话获取用户电子邮件?,react-native,email,expo,google-signin,React Native,Email,Expo,Google Signin,目前,我正在使用这段代码登录谷歌,但我无法获得用户电子邮件…有人知道如何做到这一点吗 var LoginGoogle = () => { const [request, response, promptAsync] = Google.useAuthRequest({ androidClientId: 'xxxxxxx.apps.googleusercontent.com', expoClientId: 'xxxxxxx.apps.googleusercontent
var LoginGoogle = () => {
const [request, response, promptAsync] = Google.useAuthRequest({
androidClientId: 'xxxxxxx.apps.googleusercontent.com',
expoClientId: 'xxxxxxx.apps.googleusercontent.com'
},{
scopes: ["email"]
},{});
React.useEffect(() => {
if (response?.type === 'success') {
const { authentication } = response;
console.log(response);
}
}, [response]);
return (
<GoogleSocialButton disabled={!request} onPress={() => {promptAsync()}} />
)
}
var logingogle=()=>{
const[request,response,promptAsync]=Google.useAuthRequest({
androidClientId:'xxxxxxx.apps.googleusercontent.com',
expoClientId:'xxxxxxx.apps.googleusercontent.com'
},{
范围:[“电子邮件”]
},{});
React.useffect(()=>{
如果(响应?.type=='success'){
const{authentication}=响应;
控制台日志(响应);
}
}[答复];
返回(
{promptAsync()}}/>
)
}
响应返回带有链接的对象,而不是电子邮件我在我的RN应用程序中也使用了AuthSession,我遇到了这个问题。浏览Google API文档后,发现您可以将访问令牌从useAuthRequest响应传递到访问令牌