我正在使用google_sign_in插件。
它工作得很好。但我有个问题。
我需要向后端服务器发送idToken来验证用户。
但是来自谷歌登录响应的IdToken是空的。
代码很简单
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;
print("Printing google user info");
print(googleAuth.accessToken);
print(googleAuth.idToken);
print(googleUser.displayName);
其他属性具有正确的值。但idToken为空
我用谷歌搜索了一下,然后说我需要网络客户端的id。
所以我照做了
final _googleSignIn = GoogleSignIn(clientId: webClientId);
你们能帮上忙吗?
我是不是遗漏了什么?
发布于 2021-10-09 11:39:15
我面对这个问题已经两天了,最后。(在我的例子中)这个解决方案是可行的。
https://firebase.flutter.dev/docs/installation/android#installing-your-firebase-configuration-file
com.google.gms:google-services
作为依赖项添加到android/build.gradle
中依赖关系{ // ...其他依赖类路径'com.google.gms:google-services:4.3.8‘} }
/android/app/build.gradle
中添加apply plugin: 'com.google.gms.google-services'
应用插件:'com.google.gms.google-services'
发布于 2021-01-05 18:25:44
在尝试验证用户身份之前,您必须像这样指定作用域
GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: [
'email',
'https://www.googleapis.com/auth/contacts.readonly',
"https://www.googleapis.com/auth/userinfo.profile"
],
);
然后,您可以请求用户进行身份验证。要获取isToken,请调用此方法
GoogleSignInAuthentication googleSignInAuthentication = await result.authentication;
如果您已经在云控制台中正确配置了项目,您应该可以毫无问题地获取id
https://stackoverflow.com/questions/63891637
复制相似问题