thinhle-agilityio/gatsby-source-apiserver

Oauth2 Permission Denied

Opened this issue · 2 comments

Hi

I was hoping someone might be able to point me in the right direction in implementing the auth0config for OAuth2. I'm getting "401 not authorised" every time. Here's my code (client_secret redacted):

module.exports = {
  plugins: [
    {
      resolve: "gatsby-source-apiserver",
      options: {
        typePrefix: 'internal__',
        url: `https://api.ochre.io/v1/stores/`,
        method: 'get',
        headers: {
          "Content-Type": "application/json"
        },
        name: `posts`,
        auth0Config: {
          method: "GET",
          url: "https://auth.ochre.io/oauth2/token",
          headers: {
            "content-type": "application/json"
          },
          data: {
            grant_type: "client_credentials",
            scope: "CMS RETAIL MUSIC",
            client_id: "9939492",
            client_secret: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
          },
          json: true
        },
        params: {
          results: 100
        },
        verboseOutput: true,
    }
    },
  ],
}

Has anyone used gatsby-source-apiserve for Oauth2, is it possible?

auth0Config was returning undefined.

I've forked the code and I have it working using 'axios-oauth-client'

Happy to share the code if useful. Curious what you might thing.

thanks for your contribution @jasecoop , can you submit a PR then I can have a review?