无法打开通过java google-drive-sdk共享的文件,除非用户先通过drive.google.com打开文件 [英] Unable to open file shared through the java google-drive-sdk unless user opens the file via drive.google.com first

查看:398
本文介绍了无法打开通过java google-drive-sdk共享的文件,除非用户先通过drive.google.com打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个用例是一个嵌入式编辑器,它使用Google Drive作为驱动器。我想在没有用户与drive.google.com互动的情况下这样做。嵌入程序调用我的API来创建文件,添加权限等。除了以下内容外,其他所有内容都很好:

The use case is an embeddable editor using Google Drive as, well, a drive. I want to do this without users having to interact with drive.google.com. The embedder calls my API to create files, add permissions etc. All is fine and dandy except:

Drive.Builder(transport, jsonFactory, credential)
                                .build().files().get(fileId).execute();

返回 null ,除非文件已被打开至少通过drive.google.com进行一次。无论文件是通过drive.google.com还是通过我的API与我的应用打开,这都是完全相同的一段代码。这个凭证也是一样的。

returns null unless the file has been opened at least once via drive.google.com. It's the exact same piece of code getting exercised whether the file is opened with my app via drive.google.com or via my API. The credential is the same too.

这是我的设计还是我错过了什么?

Is this by design or am I missing something?

推荐答案

您正在使用 drive.file 作用域,可能这两个应用程序都无权访问该文件。查看Google 范围文档

You are using the drive.file scope and perhaps both apps do not have access to that file. See the Google documentation for scopes.

这篇关于无法打开通过java google-drive-sdk共享的文件,除非用户先通过drive.google.com打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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