我正在使用 expo-google-app-auth 让我的用户登录我的应用。 我的代码正在运行,但我面临两个问题。 一方面,我的 console.log 不起作用,我想在我的终端中检索姓名、名字和电子邮件以进行测试,然后在我的 API 中注册客户端。 第二个问题,当我退出应用程序时,应用程序返回到登录屏幕但已经有了我的凭据。我不知道如何在登录应用程序后立即销毁或关闭此窗口。它给了我“欢迎:姓名”而不是谷歌按钮:
这里是google连接功能的代码:
signIn = async () => {
try {
const result = await Google.logInAsync({
androidClientId:
"1051966217196-fpp2cg7r886ln73ri03qqdrvdriek33s.apps.googleusercontent.com",
iosClientId:
"1051966217196-2n9sl21e06cd36o901f92u3vi07qhd9u.apps.googleusercontent.com",
scopes: ["profile", "email"],
});
if (result.type === "success") {
this.setState({
signedIn: true,
name: result.user.name,
email: result.email,
photoUrl: result.user.photoUrl,
});
console.log(this.state.name, this.state.email,)
this.props.navigation.navigate("TabBar");
return result.accessToken
} else {
console.log("cancelled");
}
} catch (e) {
console.log("error", e);
}
};