var deleteToken = require( '@stdlib/_tools/github/delete-token' );Deletes a GitHub OAuth access token.
var tokenID = 1;
var opts = {
'username': 'beep',
'password': 'boop'
};
deleteToken( tokenID, opts, clbk );
function clbk( error, info ) {
// Check for rate limit information...
if ( info ) {
console.error( 'Limit: %d', info.limit );
console.error( 'Remaining: %d', info.remaining );
console.error( 'Reset: %s', (new Date( info.reset*1000 )).toISOString() );
}
if ( error ) {
throw new Error( error.message );
}
console.log( 'Success!' );
}The function accepts the following options:
- username: GitHub username (required).
- password: GitHub password (required).
- otp: GitHub one-time password (2-factor authentication).
- useragent: user agent
string.
The function only supports basic authentication using a username and password. To authenticate with GitHub, set the username and password options.
var opts = {
'username': 'beep',
'password': 'boop'
};
deleteToken( tokenID, opts, clbk );To specify a user agent, set the useragent option.
var opts = {
'username': 'beep',
'password': 'boop',
'useragent': 'hello-github!'
};
deleteToken( tokenID, opts, clbk );If a user has two-factor authentication enabled, set the otp (one-time password) option.
var opts = {
'username': 'beep',
'password': 'boop',
'otp': '1234'
};
deleteToken( tokenID, opts, clbk );- Rate limit information includes the following:
- limit: maximum number of requests a consumer is permitted to make per hour.
- remaining: number of remaining requests.
- reset: time at which the current rate limit window resets in UTC seconds.
var deleteToken = require( '@stdlib/_tools/github/delete-token' );
var tokenID = 1;
var opts = {
'username': '<username>',
'password': '<password>',
'otp': '<otp>',
'useragent': 'beep-boop-bop'
};
deleteToken( tokenID, opts, clbk );
function clbk( error, info ) {
if ( error ) {
if ( error instanceof Error ) {
throw error;
}
console.error( error.message );
} else {
console.log( 'Success!' );
}
}Usage: ghdeletetoken [options] token_id
Options:
-h, --help Print this message.
-V, --version Print the package version.
--username username GitHub username.
--password password GitHub password.
--otp password GitHub one-time password.
-ua, --useragent ua User agent.-
If a
usernameis not provided, the implementation will attempt to infer a username by executinggit config user.name
in the current working directory.
-
If a
passwordis not provided, the user will be prompted to provide apassword. -
In addition to the
usernameandpasswordoptions, ausernameandpasswordmay also be specified byGITHUB_USERNAMEandGITHUB_PASSWORDenvironment variables. The command-line options always take precedence. -
Rate limit information is written to
stderr.
Setting a username and password using the command-line options:
$ DEBUG=* ghdeletetoken --username <username> --password <password> 1234
# => 'Deleted token 1234.'Setting a username and password using environment variables:
$ DEBUG=* GITHUB_USERNAME=<username> GITHUB_PASSWORD=<password> ghdeletetoken 1234
# => 'Deleted token 1234.'