可能的重复项
朋友们,大家好!
我已经引用了这个Google Drive SDK Exception,实际上我得到了这个错误
07-18 13:07:49.252: W/System.err(16389): com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized
07-18 13:07:49.252: W/System.err(16389): {
07-18 13:07:49.252: W/System.err(16389): "code" : 401,
07-18 13:07:49.260: W/System.err(16389): "errors" : [ {
07-18 13:07:49.260: W/System.err(16389): "domain" : "global",
07-18 13:07:49.260: W/System.err(16389): "location" : "Authorization",
07-18 13:07:49.260: W/System.err(16389): "locationType" : "header",
07-18 13:07:49.260: W/System.err(16389): "message" : "Invalid Credentials",
07-18 13:07:49.260: W/System.err(16389): "reason" : "authError"
07-18 13:07:49.267: W/System.err(16389): } ],
07-18 13:07:49.267: W/System.err(16389): "message" : "Invalid Credentials"
07-18 13:07:49.267: W/System.err(16389): }我已经花了2天来解决这个错误,但没有运气,有人实现了Google Drive API来访问文件和/或上传文件吗?
请帮帮忙
发布于 2013-07-19 04:21:38
您需要使用GoogleAccountCredential来授权和验证您的请求。
GoogleAccountCredential credential =
GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE);
Drive service = new Drive
.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential)
.build();
service.files().list().execute();https://developers.google.com/drive/quickstart-android上提供了快速入门教程
https://stackoverflow.com/questions/17717627
复制相似问题