fetching private repositories from GitHub app

184 views Asked by At

I'm building a web app that integrates with GitHub API (authentication). I'm trying to fetch the user's repositories both public and private. But both without accessToken and with accessToken return public repos only.

  1. authentication

  const provider = new GithubAuthProvider();
  provider.addScope('repo');

  const PopupSignIn = async () => {
     const result = await signInWithPopup(auth, provider);
     const credential = GithubAuthProvider.credentialFromResult(result);
     setToken(credential.accessToken)
     return credential;
  };
  1. fetching repositories
    user here is the auth credential got from getAuth()
PopupSignIn().then(() => {
   fetch(
      `https://api.github.com/users/${user.reloadUserInfo.screenName}/repos`,
      { headers: { authorization: token } }
   )
});
0

There are 0 answers