谷歌的OAuth 2.0和调试键谷歌驱动器API [英] Google OAuth 2.0 and debug key for Google Drive API

查看:166
本文介绍了谷歌的OAuth 2.0和调试键谷歌驱动器API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了在 GoogleDriveAPI 控制台Android应用程序2的客户ID:第一个为发布APK,另一个用于调试的目的。一切就OK了与发布的应用程序,但我的问题只涉及到第二个客户端ID。 我得到这个异​​常: com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAuthIOException

I've set up 2 Client IDs for Android application in the GoogleDriveAPI console: the first for the release APK and the second for Debug purposes. Everything ok with the released app, but my issue is only related to the second Client ID. I'm getting this exception: com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAuthIOException

以下行后:

Drive.Files.List request;
request = service.files().list();
String query = "mimeType='application/vnd.google-apps.folder' AND trashed=false AND title='" + title + "' AND '" + parentId + "' in parents";
request = request.setQ(query);
com.google.api.services.drive.model.FileList files = request.execute(); // <=I'm getting the exception here

preferences-&GT; Android-&GT;建立我使用ADT在Windows上,我从 Windows的&GT获得的SHA1指纹调试密钥库>对于调试模式,但谷歌驱动器API授权失败!为什么? (唯一)解决方案,我发现是使用发布客户端ID还处于调试模式,用定制的指纹(和实际工作)。

I'm using ADT on windows, I've obtained the sha1 fingerprint for debug keystore from Windows->Preferences->Android->Build for the debug mode, but the Google Drive API authorization fails! Why? The (only) solution I've found is to use the "Release" Client ID also in Debug mode, with a custom fingerprint (and that actually works).

推荐答案

试试这个: 就拿不工作(DEBUG.apk),我不知道什么是你的IDE中的* .apk文件的文件,所以我不能告诉你在哪里可以找到它,但它应该很容易。

Try this: Take the *.apk file that isn't working (DEBUG.apk), I don't know what's your IDE, so I can't tell you where to find it, but it should be easy.

  1. 在7-zip或类似unzipper打开*的.apk文件,并找到在存档META-INF \ CERT.RSA'文件。将其解压缩,比如你的... \桌面\
  2. 运行密钥工具-printcert -file ... \桌面\ CERT.RSA'。
  3. 您应该看到问题的APK文件的SHA1,它与你在控制台中注册的SHA1比较。仔细检查包名称。 PACKAGENAME-SHA1结合是授权的应用程序版本,谷歌驱动器。

我依稀记得这发生在我身上重新安装/升级我的IDE或移动项目到另一台机器(主要产生不同的调试SHA1比我注册的)。

I vaguely remember this happening to me after re-installing/upgrading my IDE or moving project to another machine (basically generating different debug SHA1 than I registered).

我知道这是一个长镜头,但是这是我使用的时候遇到麻烦的东西。希望它能帮助,祝你好运。

I know it is a long shot, but this is what I use when run into trouble. Hope it helps, Good Luck.

这篇关于谷歌的OAuth 2.0和调试键谷歌驱动器API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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