[英]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?
I am trying to get the server auth token which needs to be sent to the backend so that they can pull the data from Google Fit API but they need this token after a user allows some scopes from the Android app.我正在尝试获取需要发送到后端的服务器身份验证令牌,以便他们可以从 Google Fit API 中提取数据,但是在用户允许 Android 应用程序的某些范围后,他们需要此令牌。 My firebase and google cloud project is one for which I am using
google-services.json
file.我的 firebase 和谷歌云项目是我使用
google-services.json
文件的项目之一。 I have generated Client ID from Google API Console which is also present in google-services.json
.我从 Google API 控制台生成了客户端 ID,该控制台也存在于
google-services.json
中。 After doing all of that I am still getting server auth token as null.在完成所有这些之后,我仍然将服务器身份验证令牌作为 null。 How can I get the correct server auth code?
如何获得正确的服务器验证码?
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);
}
I am trying to get the server auth token which needs to be sent to the backend so that they can pull the data from Google Fit API but they need this token after a user allows some scopes from the Android app.我正在尝试获取需要发送到后端的服务器身份验证令牌,以便他们可以从 Google Fit API 中提取数据,但是在用户允许 Android 应用程序的某些范围后,他们需要此令牌。 My firebase and google cloud project is one for which I am using
google-services.json
file.我的 firebase 和谷歌云项目是我使用
google-services.json
文件的项目之一。 I have generated Client ID from Google API Console which is also present in google-services.json
.我从 Google API 控制台生成了客户端 ID,该控制台也存在于
google-services.json
中。 After doing all of that I am still getting server auth token as null.在完成所有这些之后,我仍然将服务器身份验证令牌作为 null。 How can I get the correct server auth code?
如何获得正确的服务器验证码?
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.