Skip to content

v1.0.0 no longer can unmarshel a single audience from client credentials using CustomClaims #81

Closed
@lita

Description

@lita

Description

I believe the upgrade to 1.0.0 and the change from github.com/dgrijalva/jwt-go to github.com/form3tech-oss/jwt-go broke using Auth0's Client Credentials. We currently use this to do integration tests. The types have changed for StandardClaims for the audience field, going from string to []string, which makes the Bearer token returned from /oauth/token endpoint not useable.

Reproduction

curl --request POST \
  --url https://<<your app>>.auth0.com/oauth/token \
  --header 'content-type: application/json' \
  --data '{"client_id":"<<YOUR ID>>","client_secret":"<<YOUR SECRET>>","audience":"https://<<your app>>.auth0.com/api/","grant_type":"client_credentials"}'

Passing that credential into the go-jwt-middleware library results in the error JWT Check failed. Error: Error parsing token: json: cannot unmarshal string into Go struct field CustomClaims.aud of type []string.

If I try to make the same call with multiple audiences or a single audience with an array "audience":["https://<>.auth0.com/api/"]) the curl call fails.

{"error":"invalid_request","error_description":"Invalid audience. Expected type 'string' but found type 'object'."}%

I also tried escaping ("audience":\["https://<<your app>>.auth0.com/api/"\]), but I get an invalid json error.

Environment

Please provide the following:

  • Version of this library used: 1.0.0
  • Version of the platform or framework used, if applicable: N/A
  • Other relevant versions (language, server software, OS, browser): N/A
  • Other modules/plugins/libraries that might be involved: github.com/form3tech-oss/jwt-go

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions