我正在尝试在 Google Drive 上备份我的 android 应用程序的应用程序数据。因此我请求访问 https://www.googleapis.com/auth/drive.appdata , https://www.googleapis.com/auth/drive.file使用 google_sign_in 包的范围。
我在 Google Developer Console 上创建了一个项目,启用了 Drive API 并将范围添加到 OAuth 同意屏幕,并添加了一个 OAuth 客户端 ID,其中包含包名称和调试 key 的 SHA-1。
如果我不请求任何范围,则应用程序可以正常工作,但请求“驱动器”范围会使同意屏幕卡住并且它会永远加载。
有什么我想念的吗?
下面是应用程序的代码和卡住的屏幕加载
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);
}();
},
),
],
),
),
)
);
}
}
最佳答案
通过评论,似乎代码工作正常并且问题是由使用的帐户引起的 - 这可能来自帐户上设置的权限。如果您仍有问题,我建议您登录 errors有关该问题的更多详细信息。
关于android - 谷歌云端硬盘同意屏幕卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57831466/