gh-get-token
v1.0.3
Published
Exchange username and password for a GitHub OAuth token
Downloads
5
Maintainers
Readme
gh-get-token
Exchange username and password for a GitHub OAuth Token
Designed for CLI apps.
Just do :-
config_obj = {
'note': 'some note',
'client_id': '',
'client_secret': ''
};
require('gh-get-token')(config_obj, function (err, token) {
if (err) {
console.log(err);
// handle error
} else {
console.log(token);
}
});
// token => abcd4567 (OAuth Token)
Want to create a single OAuth Token?
Add just note
to the config_obj
. Check out the API reference
Want to get or create an authorization for your registered app?
For this, the fields client_id
and client_secret
are required. Field note
is not required, but recommended. Checkout the API reference. Before you begin, you must register your app on GitHub, and thus, obtain the App ID and the App Secret.
Note that if you try to retrieve an existing GitHub authorization, then, you WILL NOT get the OAuth token. You will recieve an empty string. (GitHub returns the OAuth token only once. If you misplace, it then you must re-authenticate.)
In the case that you wish to forcefully create a new token for the same application, you must pass in config_obj.single_auth
as true
. This will force re-authentication and a new token to be created.
License
Copyright Siddharth Kannan 2015
Code licensed under MIT.