fusionauth-typescript-client icon indicating copy to clipboard operation
fusionauth-typescript-client copied to clipboard

breaking when optional parameters omitted

Open ulybu opened this issue 5 years ago • 2 comments

Hi,

Some parameters are optional, as per the API doc but lib breaks if not provided. This is specific of the typeScript lib, doesn't happen on node-client. It comes from the formData builder.

How to reproduce:

call

exchangeRefreshTokenForAccessToken('refreshToken', 'clientId', 'clientSecret')

Expected Result:

Request should be sent.

It should work with only those parameters, particularly, scope is optional. see doc: https://fusionauth.io/docs/v1/tech/oauth/endpoints#request-parameters-7

Actual result:

Type error at ligne https://github.com/FusionAuth/fusionauth-typescript-client/blob/2e36aa641a6e98782aef92ec0f5be671f2475819/src/FusionAuthClient.ts#L853

because scope isn't provided

TypeError: Cannot read property 'name' of undefined
at FormData._getContentDisposition (/PATH/node_modules/@fusionauth/typescript-client/node_modules/form-data/lib/form_data.js:226:40)
at FormData._multiPartHeader (/PATH/node_modules/@fusionauth/typescript-client/node_modules/form-data/lib/form_data.js:177:33)
at FormData.append (/PATH/node_modules/@fusionauth/typescript-client/node_modules/form-data/lib/form_data.js:70:21)
at FusionAuthClient.exchangeRefreshTokenForAccessToken (/PATH/node_modules/@fusionauth/typescript-client/build/src/FusionAuthClient.js:795:14)

Note:

Works on the node-client: https://github.com/FusionAuth/fusionauth-node-client/blob/3a36b95c04eb8e103967ca49c6548e6c4fdc0ef8/lib/FusionAuthClient.js#L928

Cheers

ulybu avatar May 11 '20 14:05 ulybu

Hi,

I believe this is fixed in 1.16.1. Feel free to try it out.

tyduptyler13 avatar May 15 '20 22:05 tyduptyler13

I'm using 1.31.0 and this is not fixed yet.

ngoc199 avatar Dec 07 '21 10:12 ngoc199