oauth 2.0 - Valid Google OAuth2 token unparseable? -


I have a valid OAuth2 token that Google accepts, but GoogleIdTokenVerifier can not even parse it.

ya29.1.AADtN_XcjzHgauKetBvrbgHImGFg1pjiHRQAKHyTGLJJZTTPMQJ5p-xAKtk955_4r6MdnTe3HZ08 (No worries, it has already ended).

This is on Android

  accountManager has been used. Blocked GateAutocrine (account, "oauth2: https: //www.googleapis.com/auth/userinfo.email", is true);  

When I //www.googleapis.com/oauth2/v1/tokeninfo? Calling on Access_token = ... I get a sensible result

  {"issued_to": "34951113407.apps.googleusercontent.com", "Audience": "34951113407. Apps.googleusercontent.com "," scope ":" https://www.googleapis.com /auth/userinfo.email "," expires_in ": 3175," email ":" me@gmail.com "," verified_email " : True, "access_type": "offline"}  

Therefore it must be a valid token. But when I call

  new GoogleIdTokenVerifier (new UrlFetchTransport (), JacksonFactor .getDefaultInstance ()). Verify (authToken)  

This gives me

  com.fasterxml.jackson.core.JsonParseException: Unexpected character ('A' (code 201) ): A valid value (number, string, array, object, 'true', 'wrong' or 'zero') [Source: java.io.ByteArrayInputStream@69886979; Line: 1, column: 2] at com.fasterxml.jackson.core.JsonParser._constructError (jsonparser.java:1378) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError (ParserMinimalBase.java.199) at com Com.fasterxml.jackson.core.json at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue (UTF8StreamJsonParser.java-2275) .fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar (ParserMinimalBase.java) 20. UTF8StreamJsonParser._nextTokenNotInObject (UTF8StreamJsonParser.java:788) at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken (UTF8StreamJsonParser.java:674) at com.google.api.client.json.jackson2.JacksonParser.nextToken (JacksonPers. Javas: 55) com com.google.api.client.json.JsonParser.startParsing (JsonParser.java, 1313) at com.google.api.client.json.JsonParser.parse (JsonParser.java:372). Google.api.client.json.JsonParser.parse (JsonParser.java:328) Com.google.api.client.json.JsonFactory.fromInputStream (JsonFactory.java206) at com.google.api.client.json.JsonParser.parse But at com.google.api.client.json.JsonParser.parseAndClose (JsonParser.java:140) and close (JsonParser.java158) at Com.google.api.client.json.webtoken.JsonWebSignature $ Parser.parse (JsonWebSignature .java: 480) at com.google.api.client.googleapis.auth.oauth2.GoogleIdToken.parse (GoogleIdToken.java:57) at Com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier.verify (GoogleIdTokenVerifier .java: 190)  

JsonWebSignature by debugging It seems that the token payload is just 1 .

  • Android 4.4.2
  • com.google.http- Customer: google-http-client-jackson2: 1.17.0-RC
  • com .fasterxml.jackson.core: Jackson-Core: 2.3.0 (Trying to include 2.1.3 with the transient dependency of Google-http-client-jackson) also tried Gsonfactory, the exception is different, but it Can not also be explicitly parsed by JsonWebSignature.parse ().

What did I do? Is there different tokens formatted out there?

There really are different tokens formats out there.

In OAuth2 token you have access_token - it says that your software is authorized with the scope of your request, but it does not say anything that actually requests a user request

There is another type of token expected to verify GoogleIdTokenVerifier : OpenID connect id_token . The use of many services is the same, because it means that a third party is certifying that the traffic you are seeing is from that person (more or less!).

A little more background, but the short version is that you [GoogleAuthUtil # getToken (android.content.Context, java.lang.String, java.lang.String)] (, java.lang.String , Java.lang.String) - it will return id_token as a string - or else you should definitely consider what is needed and the existing Consider requesting the openid area instead of oauth2: https: /. /www.googleapis.com/auth/userinfo.email .

I know this answer is probably too late to help you :)


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -