Basic Auth in HTTP requests

What are you trying to do? (please be as specific as possible and include relevant screenshots, code snippets, and reproduction steps)

I am trying to integrate paypal. Paypal api works on access_token. To get the access token i have to use the following api

curl -v -X POST “https://api-m.sandbox.paypal.com/v1/oauth2/token”\

2 -u “CLIENT_ID:CLIENT_SECRET”\

3 -H “Content-Type: application/x-www-form-urlencoded”\

4 -d “grant_type=client_credentials”

The problem is that I have to Encode CLIENT_ID:CLIENT_SECRET in Base64 before sending it in the API call.

I tried adding the header as Authorization. I have tried btoa() or toString(‘base64’) to convert but it doesn’t work. What am i missing?

What have you tried so far? (please link relevant docs and other forum posts)

Relevant links:

Hello @quicksaas,

can you try using globalThis.btoa()?