title: node.js / axios AUTHENTICATION_FAILURE with PayPal Subscriptions API
body: <p>I'm using <a href="https://github.com/axios/axios" rel="nofollow noreferrer">Axios</a> to activate a PayPal subscription since the <code>NODE SDK</code> doesn't support the subscription activation. For doing so I've created this method that generate a <code>PayPal</code> access token:</p>
  
  <pre><code>let getAccessToken = async () =&gt; {
      return await axios(options).then((response) =&gt; {
          return response.data.access_token
      });
  }
  </code></pre>
  
  <p>the options contains the following details:</p>
  
  <pre><code>const options = {
      method: 'post',
      headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
          'Access-Control-Allow-Credentials': true
      },
      data: qs.stringify(data),
      auth: {
          username: PAYPAL_CLIENT_ID,
          password: PAYPAL_CLIENT_SECRET
      },
      url: 'https://api.sandbox.paypal.com/v1/oauth2/token'
  }
  </code></pre>
  
  <p>this working fine but I'm having some problems activating the subscription, this is the method that handle this:</p>
  
  <pre><code>let activateSubscription = async (accessToken, subscriptionId) =&gt; {
  
      return await axios.post(
          `${baseURL}/v1/billing/subscriptions/${subscriptionId}/activate`,
          {
              headers: {
                  "Authorization": `Bearer ${accessToken}`,
                  "Content-Type": 'application/json'
              }
          }).then((data) =&gt; {
              return true;
          })
          .catch((error) =&gt; {
              console.log(error.response.data);
              return false;
          });
  }
  </code></pre>
  
  <p>Essentially I pass the generated <code>accessToken</code> and the <code>subscriptionId</code>, but I get as response this:</p>
  
  <pre><code>{
    name: 'AUTHENTICATION_FAILURE',
    message: 'Authentication failed due to invalid authentication credentials or a missing Authorization header.',
    links: [
      {
        href: 'https://developer.paypal.com/docs/api/overview/#error',
        rel: 'information_link'
      }
    ]
  }
  </code></pre>
  
  <p>My suspicion was that the generated token was incorrect, so I tried it in postman sending this request:</p>
  
  <pre><code>{{host}}/v1/billing/subscriptions/I-7D10FGKVNMD0/activate
  </code></pre>
  
  <p>and the returned content is <code>204</code> which is okay according to what doc says <a href="https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_activate" rel="nofollow noreferrer">here</a>.</p>
  
  <p>The request seems correct, what am I doing wrong?</p>