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

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

问题描述

我正在尝试将我的android应用程序的应用程序数据备份到Google云端硬盘上.因此,我请求访问

  import'package:flutter/material.dart';导入"package:google_sign_in/google_sign_in.dart";Future< GoogleSignInAccount>handleSignIn()异步{尝试 {返回等待GoogleSignIn(范围:["https://www.googleapis.com/auth/drive.appdata",'https://www.googleapis.com/auth/drive.file',],).登入();} catch(错误){打印(错误);返回null;}}void main()=>runApp(MyApp());MyApp类扩展了StatelessWidget {@override窗口小部件build(BuildContext context){返回MaterialApp(标题:"Flutter演示",主题:ThemeData(primarySwatch:Colors.blue,),家:脚手架(appBar:AppBar(标题:Text("),),身体:中心(子:列(mainAxisAlignment:MainAxisAlignment.center,子代:< Widget> [FlatButton(子级:const Text(使用Google登录"),onPressed:(){()异步{最后的signInResult =等待handleSignIn();打印(signInResult);}();},),],),),));}} 

解决方案

通过注释,似乎代码可以正常工作,并且问题是由所使用的帐户引起的-很有可能来自该帐户上设置的权限.如果您仍然遇到问题,建议记录错误问题的更多细节.

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.

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

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