How to Fix an AxiosError with Status Code 401 when Connecting a Pipedream Account to GoHighLevel using Oauth?

This topic was automatically generated from Slack. You can find the original thread here.

Hi !
I’m trying to connect a Pipedream account to GoHighLevel using Oauth. The basic auth is pretty simple and it works out of the box.

However I noticied that some endpoints need additional scopes permissions.

I have created a custom Oauth client in Pipedream with the necessary scopes. I also created an app in GoHighLevel with the right permissions. The app is installed on the GoHighLevel env.

I am currently trying to get the contacts in my GHL env using the endpoint: “https://services.leadconnectorhq.com/contacts/

Here is my code:

import { axios } from "@pipedream/platform"
export default defineComponent({
  props: {
    highlevel_oauth: {
      type: "app",
      app: "highlevel_oauth",
    }
  },
  async run({steps, $}) {
    const auth = this.highlevel_oauth.$auth;
    return await axios($, {
      url: "https://services.leadconnectorhq.com/contacts/",
      headers: {
        Authorization: `Bearer ${auth.oauth_access_token}`,
        "Version": `2021-07-28`,
      },
    })
  },
})

I am facing this issue:
AxiosError - Request failed with status code 401

{
  "message": "This authClass type is not allowed to access this scope. Please reach out to the Platform team to get it added.",
  "error": "Unauthorized",
  "statusCode": 401
}

Please find below the scopes that I used in the scope configuration.

Do you guys have any idea how to fix this ?

Thanks

image.png

Hi , you can request a new scope added via this GitHub Issue link: Sign in to GitHub · GitHub

Could you identify the specific scopes you need and include to your new ticket?

cc . I think this might not be related to the missing scope. Include you here to have a look

The customer OAuth client is actually the right way to accomplish what you’re trying to do, but that error message is coming from GogoHighLevel, and not Pipedream. Have you checked out their documentation to see if it offers any clues?

I am quite confused because the scope that is needed is already included in the list: contacts.readonly

If I can’t figure it out I will write a ticket.

On another note I tried using the high level connection without oauth (with api key)

import { axios } from "@pipedream/platform"
export default defineComponent({
  props: {
    gohighlevel: {
      type: "app",
      app: "gohighlevel",
    }
  },
  async run({steps, $}) {
    return await axios($, {
      url: `https://services.leadconnectorhq.com/contacts/`,
      headers: {
        Authorization: `Bearer ${this.gohighlevel.$auth.api_key}`,
        "Version": `2021-07-28`,
      },
    })
  },
})

However I get this error:

{
  "message": "Invalid JWT",
  "error": "Unauthorized",
  "statusCode": 401
}

I selected the account using a dropdown.

can you help out when you get a chance?

I will dig more :wink: