从谷歌驱动器打开文件总是要求离线访问 [英] Opening file from google drive always requests offline access

查看:219
本文介绍了从谷歌驱动器打开文件总是要求离线访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不需要离线访问且已经安装并由用户授权的谷歌应用程序。如果应用程序本身请求授权,则没有问题。然而,最近,每次从Google Drive用户界面打开文件时,都会显示授权提示:

 这个程序想要:
离线访问



<点击此请求仍然意味着它在下次打开文件时出现。我可以在Google云端硬盘生成的网址中看到它请求access_type:offline。我在云端控制台中看不到任何设置来控制此操作,并且它对用户非常困惑。如何防止它?



我看到一些类似的问题,但不像这样:

< a href =https://stackoverflow.com/questions/15181516/how-to-disable-offline-oauth2-access-from-google-drive-sdk-initiated-connections>如何禁用Google云端硬盘的离线OAuth2访问SDK发起的连接?

具有相同范围和离线access_type的第二授权具有意外的权限对话框

"这个应用程序想要:有离线访问当access_type =在线



看起来我找到了解决方案。
如果您不使用相同的client_id和client_secret执行OAuth2流程的第2步,则此消息将继续出现。

  @ app.route('/ open')
def drive_open_file():
code = request.args.get('code')
if code:
credentials = credentials_from_code (客户端,秘密,
https://www.googleapis.com/auth/drive.file,
代码,
redirect_uri =< WEBSITE> / open )


I have a google drive application that does not request offline access and is already installed and authorised by the user. If the application requests authorisation itself, there are no problems.

However, recently, every time a file is opened from the Google Drive UI, an authorisation prompt appears:

This app would like to:
Have offline access

Oking this request will still mean it appears the next time a file is opened. I can see in the url that Google Drive generates that it requests "access_type: offline". I see no settings in the cloud console to control this and its very confusing for users. How can it be prevented?

I see a number of similar questions but not quite like this:

How to disable offline OAuth2 access from Google Drive SDK initiated connections?

Second authorization with same scope and offline access_type has unexpected permission dialog

"This app would like to: Have offline access" when access_type=online

The App keeps asking for permission to "Have offline access", why?

解决方案

Looks like I found a solution for this. This message will keep appearing if you don't do step2 of the OAuth2 flow with the same client_id and client_secret.

@app.route('/open')
def drive_open_file():
    code = request.args.get('code')
    if code:
        credentials = credentials_from_code("client", "secret",
                               "https://www.googleapis.com/auth/drive.file",
                               code,
                               redirect_uri="<WEBSITE>/open")

这篇关于从谷歌驱动器打开文件总是要求离线访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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