401 Unauthorized no matter what I do

Using Node.js I’m attempting to use the V2 API. However, no matter what I do, I always get a 401 when attempting to access any V2 endpoint. I’ve registered my app, authorized it with my Patreon account, got the code, used said code to generate an access_token and refresh_token, but still I’m getting a 401 no matter which endpoint I try to hit. Am I missing something?

Here’s my code

  request(
    {
      url: "https://www.patreon.com/api/oauth2/v2/identity",
      headers: {
        Authorization: "Bearer " + access_token,
      },
    },
    (err, result, body) => {
      if (err) {
        console.log(err);
      } else {
        body = JSON.parse(body);
        console.log(body);
      }
    }
  );

response:

{
  errors: [
    {
      code: 1,
      code_name: 'Unauthorized',
      detail: "The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.",
      id: '3c6c5fe3-7bef-50b6-9f4a-794f01928a00',
      status: '401',
      title: 'Unauthorized'
    }
  ]
}

Any help is appreciated, I feel like I’m banging my head against a wall.

Well, no more than two minutes after I posted this, I found my answer. For anyone who stumbles upon this and is experiencing the same issue, here’s what was wrong: in my Client & API Keys I had my client set to the V1 API, not V2. As soon as I created a new V2 API Client, everything started working. So don’t do what I did.

1 Like

Yes, you should not mix anything v1 and v2 and instead only use v2 for everything.