# Calling an Identiy Provider API Issues with automating token

**URL:** <https://community.auth0.com/t/calling-an-identiy-provider-api-issues-with-automating-token/8250>\
**Category:** Get Help\
**Tags:** react, token, authorization, access-token, provider\
**Created:** [September 20, 2017, 3:54am UTC](https://community.auth0.com/t/calling-an-identiy-provider-api-issues-with-automating-token/8250 "2017-09-20T03:54:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alvis.jason](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@alvis.jason](https://community.auth0.com/u/alvis.jason)\
**Post date:** [September 20, 2017, 3:54am UTC](https://community.auth0.com/t/calling-an-identiy-provider-api-issues-with-automating-token/8250/1 "2017-09-20T03:54:40Z")

</div>

Hello,

I am well and truly stuck with calling an Identity provider API (in my case GitHub) via a React application. I have read through the documentation but the part around automating the token request is difficult to make out. [Call an Identity Provider API - Auth0 Docs](https://auth0.com/docs/tutorials/calling-an-external-idp-api)

**Settings I have (2 Clients):**

1 Single Page Application used for step 1 (below) for my login process.

1 API Explorer client (non-interactive)

**Step 1.**

I have a custom login form that uses the GitHub social connection, this works great and returns an access token, no issues here.

**Step 2.**

From what I understand I cannot use the access token from Step 1 to access the GitHub API, I have to get a new token via a post request which will then return an access token within the identities array which I can extract and use to call the GitHub API.

I have attempted this request using axios within my React App like so:

```
axios
  .post('https://name.eu.auth0.com/oauth/token', {
    headers: {
      'content-type': 'application/json'
    },
    data: {
      client_id: 'CLIENT_ID',
      client_secret: 'CLIENT_SECRET',
      audience: 'https://name.eu.auth0.com/api/v2/',
      grant_type: 'client_credentials'          
    }
  })
  .then(function(response) {
    console.log(response);
  })
  .catch(function(error) {
    console.log(error);
  });

```

But I get an error, request failed with status code 401, which means unauthorised access. I have been using my API explorer client (non-interactive) details here for the client\_id and client\_secret.

I’m not sure what I’m doing wrong, I presume I have some configuration wrong within my Auth0 account dashboard but its quite confusing to work out how it should be setup, I would love if you have a real demo somewhere.

I have used the management API on your website with a manually generated token and it works great. [Management API Reference - Auth0 Docs](https://auth0.com/docs/api/management/v2)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/calling-an-identiy-provider-api-issues-with-automating-token/8250/2 "2018-03-02T05:56:36Z")

</div>


