0
我正在涂写一些代码,用于在无头Raspberry Pi中使用有效的Google Drive API客户端应用程序对OA开发帐户进行身份验证。Google的OAuth2ForDevices不支持Drive API吗?
我在python3/pip3环境中使用py-gaugette模块(https://github.com/guyc/py-gaugette)。
的代码如下:
import gaugette.oauth
CLIENT_ID = 'xxx.apps.googleusercontent.com'
CLIENT_SECRET = 'xxx'
CLIENT_SCOPE = ['profile', 'email', 'https://www.googleapis.com/auth/drive.files']
# CLIENT_SCOPE = ['profile', 'email', 'https://www.googleapis.com/auth/calendar.readonly']
oauth = gaugette.oauth.DeviceOAuth(CLIENT_ID, CLIENT_SECRET, CLIENT_SCOPE)
if not oauth.has_token():
user_code = oauth.get_user_code()
# print "Go to %s and enter the code %s" % (oauth.verification_url, user_code)
print("Go to " + oauth.verification_url + " and enter the code: " + user_code)
oauth.get_new_token()
程序工作正常,其他API的日历API和其他几个领域。但是,对Drive API的支持没有明确规定。我尝试使用相关驱动API范围,这是错误消息:
400
b'{\n "error" : "invalid_scope"\n}'
此外,相反,我看到的页面https://developers.google.com/identity/protocols/OAuth2ForDevices提一些实验用于驱动API。
我的目标是在应用程序文件夹级别来验证用户读取&写权限的应用程序
有人可以帮助我在这里?在此先感谢!
有许多不同的方法来使用oauth。你能否更新你的问题来解释用户是谁,他们需要访问哪些账户,你的应用程序是分发还是个人的。 – pinoyyid
我认为这比Drive API本身更像是一个库和实现问题。 – noogui
嗨,我也在Google云端硬盘论坛中观察到类似的问题。显然,他们还没有机会考虑解决这个问题。我们非常清楚客户端应用程序的逻辑。特别需要API支持方面的帮助。 *为什么“https://www.googleapis.com/auth/drive.files”范围尚未在OAuthForDevices中受支持?还有一个文档* – Dmitri