Flutter 如何在Flitter中从GoogleSignIn获得更多范围?
我有一个方法,我正在使用它来获取用户的基本信息,如生日、性别和电话号码,现在我知道如何在Flitter中实现它了Flutter 如何在Flitter中从GoogleSignIn获得更多范围?,flutter,dart,google-oauth,google-signin,Flutter,Dart,Google Oauth,Google Signin,我有一个方法,我正在使用它来获取用户的基本信息,如生日、性别和电话号码,现在我知道如何在Flitter中实现它了 void signInWithGoogle(context) async { final GoogleSignIn _googleSignIn = GoogleSignIn(); try { final GoogleSignInAccount googleUser = await _googleSignIn.signIn(); final Googl
void signInWithGoogle(context) async {
final GoogleSignIn _googleSignIn = GoogleSignIn();
try {
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;
final AuthCredential credential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
final User user = (await _auth.signInWithCredential(credential)).user;
} catch (error) {
print('Google error: $error');
}
}
我希望这个答案能对你有所帮助。 您可以尝试在GoogleSignIn()方法中添加一个作用域,如下所示
GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: [
'email',
'https://www.googleapis.com/auth/contacts.readonly',
],
);
您还可以根据要访问的信息调整范围。
这是指向您可以使用的作用域的完整列表的链接
请注意,某些作用域需要应用程序验证,这在上面的链接中已经提到。好的。然后呢?访问哪个API来获取此信息,以及如何访问?