Issue making API request using logged in user's credentials

23 Views Asked by At

I am using NextAuth and Github to authenticate a user in my app. I am trying to run a TRPC query to return an authenticated user's github repo information.

const response = await fetch(`https://api.github.com/user`, {
      headers: {'Authorization': `Bearer ${account?.access_token}`,}
    });
  1. The access_token is available - it logs out
  2. The access_token is provided by NextAuth
  3. Error Message: documentation_url: "https://docs.github.com/rest" message: "Bad credentials"

I am not sure exactly what I am doing wrong. When the user authenticates into my APP, I make sure to use user scope - and this is reflected under the account.scope property and Github Authentication UI.

I would appreciate some help, thank you !

0

There are 0 best solutions below