如何禁用Google Drive SDK发起的连接的离线OAuth2访问? [英] How to disable offline OAuth2 access from Google Drive SDK initiated connections?

查看:174
本文介绍了如何禁用Google Drive SDK发起的连接的离线OAuth2访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我们的网络应用与Google云端硬盘进行整合,并且一直停留在配置Google云端硬盘用户界面启动的连接。

我们允许用户从云端硬盘打开和创建文件,但每次从云端硬盘页面启动OAuth2会话时,都会要求访问文件(看起来像drive.file已经给出的范围)以及当我不使用应用程序时执行这些操作。我假设由于离线访问而需要重新验证,这是我们从不请求和不需要的。如果没有必要,我宁可不要求用户。



我无法从Google API控制台找到禁用此功能的方法。有没有办法为Google云端硬盘用户界面启动的会话配置OAuth2网址并设置access_type?或者,如果不是这个问题,是什么原因导致当我不使用应用程序时执行这些操作以及打开文件时不断重新授权?



如果它有助于排除故障,APP ID为399581875395

解决方案

中回答在Google Drive中打开文件总是要求离线访问



看起来我找到了解决方案。
如果您不使用相同的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'm integrating our web app with Google Drive, and got stuck on configuring the conections initiated by the Google Drive UI.

We allow users to open and create files from Drive, but every time OAuth2 session is initiated from the Drive page, it asks for access to files (looks like drive.file scope, which is already given), and also to "Perform these operations when I'm not using the application". I assume the re-authentication is requested because of the offline access, which we never request and don't need. I'd rather not ask users for this if not necessary.

I could not find a way to disable this from the Google API Console. Is there a way to configure the OAuth2 url for sessions initiated from Google Drive UI and set the access_type?

Or, if that is not the issue, what causes the "Perform these operations when I'm not using the application" and constant re-authorisation when files are opened?

if it helps with troubleshooting, the APP id is 399581875395

解决方案

Answered in Opening file from google drive always requests offline access

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")

这篇关于如何禁用Google Drive SDK发起的连接的离线OAuth2访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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