badgateway / oauth2-client

OAuth2 client for Node and browsers
https://www.npmjs.com/package/@badgateway/oauth2-client
MIT License
269 stars 31 forks source link

Allow to add extraParams to token request and refresh token request #130

Closed Xbloud closed 7 months ago

Xbloud commented 10 months ago

I am using OAuth public client with authorozation code flow, refresh token and resource imdicators (RFC 8707). The mentioned RFC adds the resource parameter to the authorization, token and refresh token requests. Unfortunatelly, it is not possible to pass the resource parameter to the token request and refresh token request.

The mentioned resource parameter can be a single string or an array of strings which brings additional issue. extraParams of type Record cannot hold multiple items with the same key. Moreover, serialization to query string using UrlSearchParams does not convert a Record with a property of type array os strings correctly An example of such a Record is { resource: [ "r1", "r2"]} which should be serialized to "resource=r1&resource=r2".

larsilus commented 7 months ago

Hi, this is also needed for Microsoft Graph OAuth2 Auth Code Flow. We need to set the parameter resource=https%3A%2F%2Fgraph.microsoft.com

As of now, your lib does not work for Microsoft OAuth.

evert commented 7 months ago

Thanks, helpful to know! Support specifically for resource is planned

larsilus commented 7 months ago

Please let me know, if i can quickly test the "resource" param or support you there. I am working for a project that needs a dependency free flexible library, that also can be used with other applications like Atlassian Jira. Do you think, it will feasible to be added in a week or so (again, can i help or test?). We are currently in the process of selecting a oauth client library approach, and i like this lib here very much. Probably i can only stick to it, if microsoft can be connected.

larsilus commented 7 months ago

@evert great!

evert commented 7 months ago

@larsilus A quick test would def help ! Let me know =)