Skip to content

resource parameter not included in token request per RFC 8707 #2333

Description

@DibyodyutiMondal

Description

When the resource parameter is configured in UserManagerSettings, it is only sent in the authorization request but not in the token exchange request. This violates RFC 8707 (Resource Indicators for OAuth 2.0), which requires the resource parameter to be included in both requests.

RFC 8707 Requirement

From Section 2 of RFC 8707:

When the resource parameter is used in an authorization request to the authorization endpoint, it indicates the identity of the protected resource(s) where the client intends to use the requested access token.

When the resource parameter is used in an access token request to the token endpoint, it indicates the identity of the protected resource(s) for which the access token is being requested.

The spec makes it clear that the resource parameter should be sent in both the authorization request and the token request.

Current Behavior

const manager = new UserManager({
  authority: 'https://auth.example.com',
  client_id: 'my-client',
  redirect_uri: 'https://app.example.com/callback',
  scope: 'openid profile email',
  resource: 'https://api.example.com',  // Only sent to /authorize, not /token
});
  • Authorization request to /authorize: includes resource=https://api.example.com
  • Token request to /token: missing resource parameter ✗

Expected Behavior

The resource parameter should be automatically included in the token request when configured in settings, matching the behavior of the authorization request.

Workaround

Currently, users must manually duplicate the resource in extraTokenParams:

const manager = new UserManager({
  // ...
  resource: 'https://api.example.com',
  extraTokenParams: {
    resource: 'https://api.example.com'  // Manual workaround
  },
});

Impact

This affects OAuth providers that implement RFC 8707 and use the resource parameter to determine token format (e.g., JWT vs opaque tokens). Without the resource in the token request, the authorization server may:

  • Issue opaque tokens instead of JWT tokens
  • Fail to set the correct aud claim
  • Reject the token request entirely

(specifically, I'm using better-auth for my OIDC server)

Related Issues

Suggested Fix

In the token request logic, include the resource from settings alongside other parameters, similar to how it's handled in the authorization request.

Activity

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

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