sur*_*rrz 6 android dart google-drive-api google-signin flutter
我正在尝试在 Google Drive 上备份我的 Android 应用程序的应用程序数据。因此,我请求使用 google_sign_in 包访问https://www.googleapis.com/auth/drive.appdata、https://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)
| 归档时间: |
|
| 查看次数: |
1499 次 |
| 最近记录: |