"drive.metadata.readonly"与"drive.metadata.readonly"之间的区别在于:和"drive.readonly.metadata" [英] Difference between "drive.metadata.readonly" and "drive.readonly.metadata"

查看:62
本文介绍了"drive.metadata.readonly"与"drive.metadata.readonly"之间的区别在于:和"drive.readonly.metadata"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下 DriveScopes.DRIVE_METADATA_READONLY https://www.googleapis.com/auth/drive.readonly.metadata之间的差异是什么?换句话说,两者之间有什么区别这两种形式:

I want to ask what is the difference between DriveScopes.DRIVE_METADATA_READONLY and https://www.googleapis.com/auth/drive.readonly.metadata? In other words, what is the difference between these two forms:

https://www.googleapis.com/auth/drive.metadata.readonly //DriveScopes.DRIVE_METADATA_READONLY
https://www.googleapis.com/auth/drive.readonly.metadata

当我使用服务帐户 Drive API 一起使用时,我花了很长时间才弄清楚为什么我的应用程序会引发未经授权的异常:

When I was using service account for working with Drive API it takes me a long time to figure out, why my app was throwing unauthorized exception:

Uncaught exception from servlet
com.google.api.client.auth.oauth2.TokenResponseException: 403
{
    "error" : "access_denied",
    "error_description" : "Requested client not authorized."
}

字符串常量 DriveScopes.DRIVE_METADATA_READONLY 导致了异常.在哪种情况下我应该使用此常量?

The String constant DriveScopes.DRIVE_METADATA_READONLY was causing the exception. In which context should I use this constant?

推荐答案

这显然是Java API客户端中的错误.

That's clearly a mistake in the Java API client.

API文档指出正确的范围是:

https://www.googleapis.com/auth/drive.readonly.metadata

当您查看最新的Javadoc (在回答此问题时),您会得到:

Whereas when you look at the latest javadoc (at the time of this answer), you get :

https://www.googleapis.com/auth/drive.metadata.readonly

您应该忽略 DriveScopes 常量,并创建自己的常量,而Google Drive团队会对此进行修复.

You should ignore the DriveScopes constant and create your own constant, while the Google Drive team fixes this.

这篇关于"drive.metadata.readonly"与"drive.metadata.readonly"之间的区别在于:和"drive.readonly.metadata"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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