Google Drive 同意屏幕卡住

sur*_*rrz 6 android dart google-drive-api google-signin flutter

我正在尝试在 Google Drive 上备份我的 Android 应用程序的应用程序数据。因此,我请求使用 google_sign_in 包访问https://www.googleapis.com/auth/drive.appdatahttps://www.googleapis.com/auth/drive.file范围。

我在 Google 开发者控制台上创建了一个项目,启用了 Drive API,并将范围添加到 OAuth 同意屏幕,并添加了包含包名称和调试密钥的 SHA-1 的 OAuth 客户端 ID。

如果我不请求任何范围,该应用程序工作正常,但请求“驱动”范围会使同意屏幕卡住并且永远加载。我有什么遗漏的吗?

以下是应用程序的代码和卡住的屏幕加载 同意屏幕加载

import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';

Future<GoogleSignInAccount> handleSignIn() async {
  try {
    return await GoogleSignIn(
      scopes: [
        'https://www.googleapis.com/auth/drive.appdata',
        'https://www.googleapis.com/auth/drive.file',
      ],
    ).signIn();
  } catch (error) {
    print(error);
    return null;
  }
}

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text(""),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              FlatButton(
                child: const Text("Login with Google"),
                onPressed: () {
                  () async {
                    final signInResult = await handleSignIn();
                    print(signInResult);
                  }();
                },
              ),
            ],
          ),
        ),
      )
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

Oma*_*att 0

通过评论,代码似乎运行良好,问题是由所使用的帐户引起的 - 可能是由于帐户上设置的权限造成的。如果您仍然遇到问题,我建议记录错误以获取问题的更多详细信息。