jaredhanson / passport-github

GitHub authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-github/?utm_source=github&utm_medium=referral&utm_campaign=passport-github&utm_content=about
MIT License
537 stars 290 forks source link

"Unauthorized" when using example app #3

Closed connor closed 12 years ago

connor commented 12 years ago

Hi Jared,

This is looking great, and I'm hopeful to use this in my app. One quick question, though (and this may be how I've set up my app on github).

When I run the example application included in the repo, and replace the GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET with my own credentials, after clicking Login with Github, it takes me to the following URL: http://localhost:3000/auth/github?error=redirect_uri_mismatch, and I get an Unauthorized error in the browser.

Obviously the error is a there's an inconsistency in the redirect_uri (which, from my understanding, is the "callback URL" on github's applications page).

So, what I did was make the callback URL on github's applications page blank, which I assumed would let me set it programmatically via the callbackURL parameter when initializing a new GitHubStrategy. But that's not working.

Do you have any ideas on what I may be doing wrong? I've tried to set the callbackURL on github's apps page and programmatically, but I'm still getting the _redirect_urimismatch error.

Any help would be appreciated, and thanks for this!

jaredhanson commented 12 years ago

The "Callback URL" on the GitHub applications settings must match the callbackURL option to the GitHubStrategy.

For example, in my local test setup, I have them both set to http://127.0.0.1:3000/auth/github/callback

Also, make sure you are using your application's client ID and secret (not your GitHub account credentials), which you probably are but I figured it couldn't hurt to clarify :)

Let me know if that works.

connor commented 12 years ago

Hey Jared,

Awesome. Yeah - I'm using my client ID and secret - it was just the callback URL that was confusing me a bit.

In class now but will let you know if that works.

Thanks!

connor commented 12 years ago

Worked perfectly. Thank you!