[英]Google Api and android Oauth INVALID_AUDIENCE error
I am getting a GoogleAuthException: Unknown error
, while doing a GoogleAuthUtil.getToken
. 我得到一个GoogleAuthException: Unknown error
,同时做一个GoogleAuthUtil.getToken
。
Just before the exception I see 就在我看到的例外之前
GLSUser: GLS error: INVALID_AUDIENCE <email> audience:server:client_id:xxx.apps.googleusercontent.com
I have set the SHA1 from my release key , the package name, to the google api project. 我已将SHA1从我的发布密钥(包名称)设置为google api项目。 (Which by the way is being used successfully for GCM. ) (顺便说一句,这是成功用于GCM的。)
Looks like that should work; 看起来应该有用; here's the scope-init code from my app which does work. 这是我的应用程序中的scope-init代码,它可以正常工作。
private static final String SCOPE = "audience:server:client_id:" + SERVER_CLIENT_ID;
So it smells to me like there's a problem with the client id. 因此,我觉得客户端ID存在问题。 Remember that 记住这一点
It's the client ID from #3 that goes after ...:client_id: 它是#3之后的客户端ID ...:client_id:
In the interest of documenting my issue, 为了记录我的问题,
I had the same INVALID_AUDIENCE error come back from a Google sign-in through an AWS Mobile Hub generated sample app. 我通过AWS Mobile Hub生成的示例应用从Google登录中获得了相同的INVALID_AUDIENCE错误。 A few things to check, 要检查的一些事情,
Like Tim Bray notes aboves, make your client id a valid web client id (not Android). 就像Tim Bray注意到的那样,让你的客户端ID成为有效的Web客户端ID(不是Android)。 But also have an android client id that has both the proper SHA-1 Fingerprint (found in debug.keystore which Android Studio uses to sign debug builds when you click Run) and package name. 但是也有一个android客户端ID,它具有正确的SHA-1指纹(在debug.keystore中找到,Android Studio用来在单击Run时签署调试版本)和包名称。
NOTE: The package name listed in the AndroidManifest.xml is not always the actual package name. 注意:AndroidManifest.xml中列出的软件包名称并不总是实际的软件包名称。 To find the definitive package name, go to the build.gradle file and see the applicationId field. 要查找确定的包名称,请转到build.gradle文件并查看applicationId字段。 Be sure to input the right package name in the Developers Console when you configure the Android Client Id. 配置Android客户端ID时,请务必在Developers Console中输入正确的软件包名称。
Happened to one on my team although it worked ok on my device. 虽然它在我的设备上工作正常,却发生在我的团队中。 It turned out to be because of a different debug.keystore
on our eclipse installations. 原来是因为我们的eclipse安装中有一个不同的debug.keystore
。
To solve it we've copied the company's debug.keystore
file to ~/.android/
(this is the dir on a mac, it's different on linux and windows) 为了解决这个问题,我们将公司的debug.keystore
文件复制到了~/.android/
(这是mac上的dir,在linux和windows上是不同的)
Solve this by deleting your debug.keystore found in your .android folder, then run the new project again to generate a new debug.keystore file. 通过删除.android文件夹中找到的debug.keystore来解决此问题,然后再次运行新项目以生成新的debug.keystore文件。 Then finally generate a new SHA-1 signing-certificate for Google API. 然后,最终为Google API生成新的SHA-1签名证书。
Also you have to set up oAuth authorization screen in your Google API Console. 您还必须在Google API控制台中设置oAuth授权屏幕。
That was why I got this error 这就是我收到这个错误的原因
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.