谷歌云端硬盘同意屏幕卡住 [英] Google Drive Consent Screen Stuck

查看:23
本文介绍了谷歌云端硬盘同意屏幕卡住的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Google Drive 上备份我的 android 应用程序的应用程序数据.因此,我请求访问

import 'package:flutter/material.dart';导入包:google_sign_in/google_sign_in.dart";未来<GoogleSignInAccount>handleSignIn() 异步 {尝试 {返回等待谷歌登录(范围:['https://www.googleapis.com/auth/drive.appdata','https://www.googleapis.com/auth/drive.file',],).登入();} 捕捉(错误){打印(错误);返回空值;}}无效的主要()=>运行应用程序(我的应用程序());MyApp 类扩展 StatelessWidget {@覆盖小部件构建(BuildContext 上下文){返回材料应用程序(标题:颤振演示",主题:主题数据(primarySwatch:颜色.蓝色,),家:脚手架(应用栏:应用栏(标题:文本("),),身体:中心(孩子:列(mainAxisAlignment: MainAxisAlignment.center,孩子们:<小部件>[扁平按钮(child: const Text("用谷歌登录"),按下:(){() 异步 {最终signInResult = 等待handleSignIn();打印(签到结果);}();},),],),),));}}

解决方案

查看评论,似乎代码工作正常,问题是由使用的帐户引起的 - 可能来自帐户上设置的权限.如果您仍然遇到问题,我建议您记录 错误问题的更多细节.

I am trying to backup the application data of my android app on Google Drive. Therefore I request access to the https://www.googleapis.com/auth/drive.appdata, https://www.googleapis.com/auth/drive.file scopes using the google_sign_in package.

I created a project on the Google Developer Console, enabled the Drive API and added the scopes to the OAuth Consent Screen and added an OAuth Client ID with the package name and the SHA-1 of the debug key.

The application works fine if I don't request any scopes, requesting the "drive" scopes however makes the consent screen being stuck and it keeps loading forever. Is there anything that I am missing?

Below are the code of the application and the stuck screen loading

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);
                  }();
                },
              ),
            ],
          ),
        ),
      )
    );
  }
}

解决方案

Going through the comments, it seems that the code works fine and the issue was caused by the account used - it's likely from the permission set on the account. If you're still having issues, I suggest logging the errors for more details of the issue.

这篇关于谷歌云端硬盘同意屏幕卡住的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆