INVALID_KEY message trying to authenticate through

2019-04-09 05:30发布

I am trying to authenticate the user following this gist by Ian Barber. The button asks for the user account, but it never gets to show the authorization dialog and instead exits with the message "An internal error ocurred". Logcat shows this:

W/GLSUser ( 4353): Status from wire: INVALID_KEY status: null
W/GLSUser ( 4353): Status from wire: INVALID_KEY status: null
E/GLSUser ( 4353): Empty consent data
I/GLSUser ( 4353): GLS error: INVALID_KEY icoloma@gmail.com oauth2:https://www.googleapis.com/auth/plus.login
W/GLSUser ( 4353): Status from wire: Unknown status: UNKNOWN

The certificate used to sign my app is the same configured at my Google API Console page, and the package name is also the same.

4条回答
趁早两清
2楼-- · 2019-04-09 06:13

One more reason why this error occurs:

If you have a sub-package, ensure you only mention your application's main package in the developer's console, not the sub-package.

ex: If your App is under com.example.myapp, if your G+ login activity is under package com.example.myapp.authentication, in the developer's console, the package name you enter should be com.example.myapp (leave out the subpackage)

查看更多
甜甜的少女心
3楼-- · 2019-04-09 06:15

This happens when your certificate has been added in the "Simple API Access" section instead of "Client ID for installed applications". In the Google API console of your project click "Create an OAUTH2 client ID" (NOT "Create new Android Key"), select "Android" and introduce your SHA1 and package.

查看更多
对你真心纯属浪费
4楼-- · 2019-04-09 06:24

In my case this error occurred probably because I used sha256withrsa algorithm to sign my APK instead of sha1withrsa. Probably - I don't know for certain as I will not change my signature keys just because Google API is dumb.

查看更多
【Aperson】
5楼-- · 2019-04-09 06:36

I was getting a similiar error:

772-799/com.google.process.gapps W/GLSUser﹕ GoogleAccountDataService.getToken()
05-21 13:23:50.231      772-799/com.google.process.gapps W/GLSActivity﹕ [art] Status from wire: INVALID_KEY status: null
05-21 13:23:50.231      772-799/com.google.process.gapps W/GLSActivity﹕ [art] Status from wire: INVALID_KEY status: null
05-21 13:23:50.235      772-799/com.google.process.gapps I/GLSUser﹕ GLS error: INVALID_KEY my-gmail@address.com oauth2:https://www.googleapis.com/auth/plus.login
05-21 13:23:50.235      772-799/com.google.process.gapps W/GLSActivity﹕ [art] Status from wire: Unknown status: UNKNOWN

I fixed it by signing the APK using a keystore I generated. The keystore SHA was added to our Google Developer console.

查看更多
登录 后发表回答