adyen-node-api-library icon indicating copy to clipboard operation
adyen-node-api-library copied to clipboard

docs: update basic auth example

Open Axfan opened this issue 1 year ago • 5 comments

Description Update the basic auth example to include application name.

It appears that applicationName is a required parameter for basic auth to work.

https://github.com/Adyen/adyen-node-api-library/blob/d9480ffbb9068a325561ca6a5cb8e50e7ee0354e/src/client.ts#L83

Axfan avatar Sep 21 '22 22:09 Axfan

hey @Axfan,

Thanks for raising this issue. This field is only used to set the user-agent field in the request headers, and should not be required.

Can you maybe elaborate on the issues you are running into?

Kind Regards, Wouter Adyen

wboereboom avatar Sep 23 '22 17:09 wboereboom

hi @wboereboom,

When the field is not added to the client config basic auth does not work.

I believe the line I linked is the culprit.

Should I update this PR to remove the requirement for applicationName?

Thanks, Adam

Axfan avatar Sep 23 '22 18:09 Axfan

hi @Axfan,

Can you please elaborate on the errors you are getting? I am unable to reproduce your issue. Creating a request without an applicationName works fine on our end.

Kind Regards, Wouter Adyen

wboereboom avatar Sep 23 '22 18:09 wboereboom

hi @wboereboom,

thank you for the quick reply :)

const client =  new Client({username: user, password: pass, environment: env);
const management = new Management(client);
const response = await management.Me.retrieve()

is giving me a 401 error unless I add applicationName

I believe the cause is this line

https://github.com/Adyen/adyen-node-api-library/blob/d9480ffbb9068a325561ca6a5cb8e50e7ee0354e/src/client.ts#L83

which causes the username/password not to be set in the config unless you also supply the application name

Axfan avatar Sep 23 '22 19:09 Axfan

Hey @Axfan,

Totally agree with your issue now, I got it. I'll make another internal ticker to look into this. As far as I am able to tell there is no reason why you should need the application name when authenticating through basic auth.

Please note that this bug only occurs for basic auth. When using an API key this should not be a problem.

Kind Regards, Wouter Adyen

wboereboom avatar Sep 23 '22 20:09 wboereboom