问题
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