GoogleAuth create: Invalid JWT: Failed audience check

1,184 views
Skip to first unread message

Tim Ross

unread,
Nov 12, 2018, 11:43:13 AM11/12/18
to vert.x
When authenticating  the google apis, I am getting failure from google:

WARNING: Googleapi oauth2 failed: io.vertx.core.impl.NoStackTraceThrowable: Bad Request: {
  "error": "invalid_grant",
  "error_description": "Invalid JWT: Failed audience check. The right audience is https://oauth2.googleapis.com/token"
}


I used the following 3.5.4 vertx api to authenticate:


    OAuth2Auth authProvider = GoogleAuth.create(vertx, serviceAccountJson);

    authProvider.authenticate(new JsonObject().put("scope", ""https://www.googleapis.com/auth/devstorage.read_write", resr-> {...});



I attempted google's suggested change by making a copy of GoogleAuth.create() , and authentication succeeds, but the refresh of the access token seems to failing.  I added my own refresh, and i was still getting these failures from the OAuth2Auth Layer:

   io.netty.channel.AbstractChannel$AnnotatedSocketException: Network is unreachable: oauth2.googleapis.com/2607:f8b0:4009:80f:0:0:0:200a:443

Any suggestions?

Thanks,
Tim





Tim Ross

unread,
Nov 12, 2018, 4:46:17 PM11/12/18
to vert.x
Ignore the part about the refresh not working.  The token refresh works fine after changing the audience to googles suggested https://oauth2.googleapis.com/token
Reply all
Reply to author
Forward
0 new messages