Auth0 Home Blog Docs

UnauthorizedError: jwt audience invalid. expected: http://api.mypgguru.com

I am trying to login to android app using auth0 and access my API created in auth0 dash dashboard after success full login i am using access token to post to my api endpoint but getting unauthorized Error: jwt audience invalid.
my api identifier is correct but still getting error.

My code is:

auth0 = new Auth0(this);
auth0.setLoggingEnabled(true);
auth0.setOIDCConformant(true);

WebAuthProvider.init(auth0)
.withScheme(“demo”)
withAudience(“http://api.mypgguru.com”)
withParameters(map)
.withScope(" openid profile& email offline_access read:current_user update:current_user_metadata")
.start(this, webCallback);

Hi there @vizlane and welcome to Auth0’s Community! After taking a look at your code snippit above I wanted to make sure that you could successfully hit your api end point through postman when testing the access in general. Furthermore it’s important to when calling the audience to call it with the period in the beginning like .withAudience. I have included the documentation for quick referencing. Thanks in advance!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.