从谷歌驱动器打开文件始终请求脱机访问

时间:2014-02-04 16:03:11

标签: google-drive-api

我有一个google驱动器应用程序,它不会请求脱机访问,并且已经由用户安装和授权。如果应用程序本身请求授权,则没有问题。

但是,最近,每次从Google云端硬盘用户界面打开文件时,都会显示授权提示:

This app would like to:
Have offline access

这个请求仍然意味着它会在下次打开文件时出现。我可以在网址中看到Google云端硬盘生成请求“access_type:offline”。我发现云控制台中没有任何设置可以控制这一点,而且对用户来说非常困惑。如何预防?

我看到了许多类似的问题但不完全像这样:

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?

1 个答案:

答案 0 :(得分:0)

看起来我找到了解决方案。 如果您没有使用相同的client_id和client_secret执行OAuth2流的step2,则此消息将一直显示。

@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")
相关问题