# Cannot get a list of GitHub repositories via Auth0

**URL:** <https://community.auth0.com/t/cannot-get-a-list-of-github-repositories-via-auth0/87742>\
**Category:** Get Help\
**Tags:** github, auth0\
**Created:** [July 27, 2022, 12:30pm UTC](https://community.auth0.com/t/cannot-get-a-list-of-github-repositories-via-auth0/87742 "2022-07-27T12:30:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![altern](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/altern/32/33478_2.png) [@altern](https://community.auth0.com/u/altern)\
**Post date:** [July 27, 2022, 12:30pm UTC](https://community.auth0.com/t/cannot-get-a-list-of-github-repositories-via-auth0/87742/1 "2022-07-27T12:30:40Z")

</div>

I am trying to list GitHub repositories in my app after the user has successfully authenticated with Auth0:

```auto
import React, { useEffect, useState } from 'react';
import { useAuth0 } from '@auth0/auth0-react';

const Repositories = () => {
  const { getAccessTokenSilently, user } = useAuth0();
  const [repositories, setRepositories] = useState(null);

  useEffect(() => {
    (async () => {
      try {
        const token = await getAccessTokenSilently({
          audience: 'https://api.github.com/',
          scope: 'public_repo',
        });
        console.log("Token:" + token)
        const response = await fetch('https://api.github.com/users/' + user.nickname + '/repos', {
          headers: {
            Accept: `application/vnd.github+json`,
            Authorization: `token ${token}`,
          },
        });
        console.log(response)
        setRepositories(await response.json());
      } catch (e) {
        console.error(e);
      }
    })();
  }, [getAccessTokenSilently, user]);

  if (!repositories) {
    return <div>Loading...</div>;
  }

  return (
    <ul>
      {repositories.map((repository, index) => {
        return <li key={index}>{repository.name}</li>;
      })}
    </ul>
  );
};

export default Repositories;

```

But it does not work. I get an error in the console `Error: Service not found: https://api.github.com/`.

Somebody recommended to add [api.github.com](http://api.github.com) to the list of my Auth0 APIs. I did that and now I am getting 401 unauthorized response. On closer inspection, the token that is returned as a result of getAccessTokenSilently() call does not really fit the GitHub format (gho\_ahdfhasdhfahs) and is longer than expected.

What am I going wrong? Are there any Auth0 examples that show how to authenticate against GitHub API to use it in my application using the user on my website authenticated with Auth0?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [July 28, 2022, 9:09pm UTC](https://community.auth0.com/t/cannot-get-a-list-of-github-repositories-via-auth0/87742/3 "2022-07-28T21:09:02Z")

</div>

Hi @altern,

The tokens you are getting from `getAccessTokenSilently` are not tokens that can be used with the GitHub API. These tokens are issued by Auth0 and are meant for use in your apps and APIs.

In order to get a GitHub access token, you must have the user log in with their GH account and get their [Identity Provider Access Tokens](https://auth0.com/docs/secure/tokens/access-tokens/identity-provider-access-tokens).

Let me know if you have questions about it.

---

<div class="post-metadata">

**Author:** ![altern](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/altern/32/33478_2.png) [@altern](https://community.auth0.com/u/altern)\
**Post date:** [July 29, 2022, 10:18am UTC](https://community.auth0.com/t/cannot-get-a-list-of-github-repositories-via-auth0/87742/4 "2022-07-29T10:18:12Z")

</div>

Is there a code example somewhere for this?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [July 29, 2022, 4:36pm UTC](https://community.auth0.com/t/cannot-get-a-list-of-github-repositories-via-auth0/87742/5 "2022-07-29T16:36:41Z")

</div>

I don’t think there is a code sample for this specific use-case.

You can find an example of how to request the user from the management API here:

[https://auth0.com/docs/api/management/v2/#!/Users/get\_users\_by\_id](https://auth0.com/docs/api/management/v2/#!/Users/get_users_by_id)

Calls to the management API should be done from a secure backed.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [September 30, 2022, 11:06pm UTC](https://community.auth0.com/t/cannot-get-a-list-of-github-repositories-via-auth0/87742/6 "2022-09-30T23:06:57Z")

</div>


