Golang validation failed, invalid audience claim (aud)

I have successfully created a frontend using the vanilla JS Spa started. This logs in and when I silently get a token and request to my API this works fine.

On my Go server I have implemented auth0-golang-api-samples/01-Authorization-RS256 at master · auth0-samples/auth0-golang-api-samples · GitHub

This is now throwing an error:

Encountered error while validating JWT: jwt invalid: expected claims not validat
ed: square/go-jose/jwt: validation failed, invalid audience claim (aud)

if len(e.Audience) != 0 {
		for _, v := range e.Audience {
			if !c.Audience.Contains(v) {
				return ErrInvalidAudience

I have noticed it failing in here. However when I look at the audiences it get in the first index:


Which is definitely not what I see in the JWT token for my audience.

Has anyone had issues like this?

Hey there!

In order to handle that most effectively I would encourage you to raise it as a GitHub issue in the repo you referenced above and then share the link to it here so we can ping the repo maintainers. Thank you!

1 Like