[英]Did anyone manage to get the id token from google sign in (Flutter)
[英]How to get valid Server Auth Token using Google Sign In Package when I have a valid client ID from developers console in Flutter app?
我正在尝试获取需要发送到后端的服务器身份验证令牌,以便他们可以从 Google Fit API 中提取数据,但是在用户允许 Android 应用程序的某些范围后,他们需要此令牌。 我的 firebase 和谷歌云项目是我使用google-services.json
文件的项目之一。 我从 Google API 控制台生成了客户端 ID,该控制台也存在于google-services.json
中。 在完成所有这些之后,我仍然将服务器身份验证令牌作为 null。 如何获得正确的服务器验证码?
void connectWithGoogleFit() async {
final GoogleSignIn googleSignIn = GoogleSignIn(
clientId:
'116565654179-8764764.apps.googleusercontent.com',
scopes: <String>[
'email',
'https://www.googleapis.com/auth/fitness.activity.read',
]);
final GoogleSignInAccount googleUser = await googleSignIn.signIn();
final GoogleSignInAuthentication googleSignInAuthentication =
await googleUser.authentication;
String serverAuthToken = googleSignInAuthentication.serverAuthCode;
print('token');
print(serverAuthToken);
}
我正在尝试获取需要发送到后端的服务器身份验证令牌,以便他们可以从 Google Fit API 中提取数据,但是在用户允许 Android 应用程序的某些范围后,他们需要此令牌。 我的 firebase 和谷歌云项目是我使用google-services.json
文件的项目之一。 我从 Google API 控制台生成了客户端 ID,该控制台也存在于google-services.json
中。 在完成所有这些之后,我仍然将服务器身份验证令牌作为 null。 如何获得正确的服务器验证码?
void connectWithGoogleFit() async {
final GoogleSignIn googleSignIn = GoogleSignIn(
clientId:
'116565654179-8764764.apps.googleusercontent.com',
scopes: <String>[
'email',
'https://www.googleapis.com/auth/fitness.activity.read',
]);
final GoogleSignInAccount googleUser = await googleSignIn.signIn();
final GoogleSignInAuthentication googleSignInAuthentication =
await googleUser.authentication;
String serverAuthToken = googleSignInAuthentication.serverAuthCode;
print('token');
print(serverAuthToken);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.