Difference between “drive.metadata.readonly” and “drive.readonly.metadata”

↘锁芯ラ 提交于 2020-07-22 21:31:06

问题


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

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."
}

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


回答1:


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

The API documentation states that the correct scope is :

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

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

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

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



来源:https://stackoverflow.com/questions/28310071/difference-between-drive-metadata-readonly-and-drive-readonly-metadata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!