Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何在Flitter中从GoogleSignIn获得更多范围?_Flutter_Dart_Google Oauth_Google Signin - Fatal编程技术网

Flutter 如何在Flitter中从GoogleSignIn获得更多范围?

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

我有一个方法,我正在使用它来获取用户的基本信息,如生日、性别和电话号码,现在我知道如何在Flitter中实现它了

 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来获取此信息,以及如何访问?