2 / 2
Jun 2024

I’am having an error validating a JWT issued by auth0 with multiple audiences.

"json: cannot unmarshal array into Go struct field accessTokenData.aud of type string"

I’am using the Authorization: Bearer <token> header from a SPA (angular). I cannot use the jwtTokenString header because I get a CORS error.

So, reading the RFC 7519, I found that :

In the general case, the “aud” value is an array of case-sensitive strings, each containing a StringOrURI value . In the special case when the JWT has one audience, the “aud” value MAY be a single case-sensitive string containing a StringOrURI value.

So the pb seems to be at your side because you don’t support this multiple audiences token.

Is there any chances to have this kind of JWT working with your api?

thank you

1 month later

I have the exact same issue! I’m also using angular and cannot set the jwtTokenString header because I get a CORS error. I also agree that we shouldn’t have to do that in the first place, because Mongo should be able to marshal an array of aud.