Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.
This repository has been archived by the owner on May 21, 2022. It is now read-only.

ParseWithClaims: getting json error when processing JWT that has multiple values for audience #348

Open
@jeffkayser2

Description

I am using JWT tokens generated by Auth0 and oauth2. The token payload looks like this:

{ "iss": "https://redacted.auth0.com/", "sub": "google-oauth2|redacted", "aud": [ "https://redacted:443/app/v1", "https://redacted.auth0.com/userinfo" ], "iat": 1565196366, "exp": 1565282766, "azp": "redacted", "scope": "openid profile email", "permissions": [ "admin" ] }

Because the audience is multi-valued, I am getting parsing error when trying to read the claims.

My parsing code looks like this:

type CustomClaimType struct { Permissions []string json:"permissions"Scope string json:"scope" jwt.StandardClaims }

. . .

// Now parse the token parsedToken, err := jwt.ParseWithClaims(bearerToken, &CustomClaimType{}, auth0ValidationKeyGetter) if err != nil { log.Printf("Got error parsing token: " + err.Error()) return nil, false, err }

When I run this, I get an error:

Got error parsing token: json: cannot unmarshal array into Go struct field CustomClaimType.aud of type string

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions