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.
- 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;
};
- fetching repositories
user
here is the auth credential got fromgetAuth()
PopupSignIn().then(() => {
fetch(
`https://api.github.com/users/${user.reloadUserInfo.screenName}/repos`,
{ headers: { authorization: token } }
)
});