Description
Description 📓
The OAuth provider configuration object includes options (e.g. authorization
, token
, and userinfo
) to configure how each provider handles the various stages of the OAuth flow.
While a mechanism for token rotation is explained in the documentation, there is no way to contribute the token refresh code to the set of built-in OAuth providers. I believe allowing this configuration to be shared with other developers through a built-in mechanism would be incredibly beneficial to the users of this library, even if the token rotation is not automatically executed.
In short, my proposal would be to add the following option to the OAuth provider configuration object :
{
// ...
/**
* Endpoint that refreshes OAuth tokens and returns a new `access_token` and `refresh_token`.
*/
refresh: EndpointHandler<
RefreshParams,
{
// unsure about what goes here
},
{ tokens: TokenSet }
>;
// ...
}
where RefreshParams
would be something like:
interface RefreshParams {
request_uri?: string;
grant_type?: string;
// Possibly more
}
This would allow developers to share the code for OAuth token refresh with the community. I don't foresee specific issues with such an extension.
Note that while I likely won't have time to implement a full automatic refresh flow, I'd be willing to contribute this specific extension (and a couple configurations for existing providers) as long as someone can offer help figuring out the right method signature.
How to reproduce ☕️
N/A
Contributing 🙌🏽
Yes, I am willing to help implement this feature in a PR