Generating accessToken doesnt work

Hi guys im stuck here for hours now


what im trying to do - i ask a user to login via github and show their both public and private repositry

my sign in func -

export const signIn = async () => {
  await authClient.signIn.social({
    provider: "github",
    callbackURL: "/dashboard",
  });
};



all logs - (see the img) i have 24 public repos and 5 private

const accessToken = await getProviderAccessToken("github");
console.log("accessToken : " + accessToken);
const username = await getGitHubUser(accessToken);
console.log("GitHub Username: " + username);
const data = await getUserRepos("", accessToken);
console.log("repos count : ", data.length);


getting all repos
export async function getUserRepos(username: string, token: string) {
  const url = "https://api.github.com/user/repos?type=all";

  const response = await fetch(url, {
    headers: {
      Accept: "application/vnd.github+json",
      Authorization: `Bearer ${token}`,
      "X-GitHub-Api-Version": "2022-11-28",
    },
  });

  if (!response.ok) {
    throw new Error(`GitHub API error: ${response.status}`);
  }

  const repos = await response.json();
  return repos;
}



currently by using the generated accesstoken when passing while fetching repos give only public repos but if i generate my own personal accesstoken through github page https://github.com/settings/tokens and pass it inside the getUserRepos func i get both public and private repos
image.png
GitHub
GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.
Was this page helpful?