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.
Description
When the
resourceparameter is configured inUserManagerSettings, 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:
The spec makes it clear that the resource parameter should be sent in both the authorization request and the token request.
Current Behavior
/authorize: includesresource=https://api.example.com✓/token: missingresourceparameter ✗Expected Behavior
The
resourceparameter 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:Impact
This affects OAuth providers that implement RFC 8707 and use the
resourceparameter to determine token format (e.g., JWT vs opaque tokens). Without the resource in the token request, the authorization server may:audclaim(specifically, I'm using better-auth for my OIDC server)
Related Issues
Suggested Fix
In the token request logic, include the
resourcefrom settings alongside other parameters, similar to how it's handled in the authorization request.