passport-github-token
Passport strategy for authenticating with GitHub access tokens using the OAuth 2.0 API.
This module lets you authenticate using GitHub in your Node.js applications. By plugging into Passport, GitHub authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
Installation
npm install passport-github-token
Usage
Configure Strategy
The GitHub authentication strategy authenticates users using a GitHub account and OAuth 2.0 tokens.
The strategy requires a verify
callback, which accepts these credentials and calls next
providing a user, as well as options
specifying a app ID and app secret.
var GitHubTokenStrategy = ; passport;
Authenticate Requests
Use passport.authenticate()
, specifying the github-token
strategy, to authenticate requests.
For example, as route middleware in an Express application:
app;
Or if you are using Sails framework:
// AuthController.jsmoduleexports = { passportreq res; };
The request to this route should include a GET or POST data with the keys access_token
and optionally, refresh_token
set to the credentials you receive from GitHub.
GET /auth/github?access_token=<TOKEN>
Issues
If you receive a 401 Unauthorized
error, it is most likely because you have wrong access token or not yet specified any application permissions.
Once you refresh access token with new permissions, try to send this access token again.