Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Access Token Invalid #1418

Closed
2 tasks done
xdega opened this issue Feb 12, 2024 · 1 comment
Closed
2 tasks done

Github Access Token Invalid #1418

xdega opened this issue Feb 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@xdega
Copy link

xdega commented Feb 12, 2024

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When using the GitHub OAuth Provider, I am unable to make valid API requests to GitHub with the access_token contained in session data that is returned. Login is successful, but using the access_token returns a 401, with "Bad Credentials" from GitHub. I can confirm that using the same access_token in a raw CURL request outside of my app returns the same error.

To Reproduce

  1. Create a SvelteKit project
  2. Create a GitHub Application (OAuth 2.0)
  3. Add Supabase Auth, with GitHub Provider
  4. Add login to app with the following code:
  async function signInWithGitHub() {
    const { error } = await supabase.auth.signInWithOAuth({
      provider: "github",
      options: {
        scopes: "repo"
      }
    });
    // ...
  1. Log in to app
  2. Retrieve the access token like so:
    supabase.auth.onAuthStateChange((event, session) => {
      // TODO: Temp for dev purposes
      console.log("Session: ", session);
    });
  1. Attempted to use the access_token included in the session object as a bearer token in auth header, via cURL request to eliminate other variables. And hit any REST endpoint in the GitHub API
  2. See that this token fails.

Expected behavior

Should successfully access the GitHub API

System information

  • OS: OSX
  • Version of supabase-js: "@supabase/supabase-js": "^2.39.3"
  • Bun Runtime

Additional context

Have been blocked on this for at least 2 weeks now.

@xdega xdega added the bug Something isn't working label Feb 12, 2024
@J0
Copy link
Contributor

J0 commented Feb 13, 2024

Hey!

Could you try using the provider_token in the session response instead? The access_token is typically used for authenticating against Supabase Auth while the provider token might be more relevant when access oauth provider related endpoints.

Going to close for now but feel free to re-open if the issue persists

@J0 J0 closed this as completed Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants