Skip to content

Latest commit

 

History

History

delete-token

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Delete Token

Delete a GitHub OAuth access token.

Usage

var deleteToken = require( '@stdlib/_tools/github/delete-token' );

deleteToken( id, options, clbk )

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 );

Notes

  • 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.

Examples

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!' );
    }
}

CLI

Usage

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.

Notes

  • If a username is not provided, the implementation will attempt to infer a username by executing

    git config user.name

    in the current working directory.

  • If a password is not provided, the user will be prompted to provide a password.

  • In addition to the username and password options, a username and password may also be specified by GITHUB_USERNAME and GITHUB_PASSWORD environment variables. The command-line options always take precedence.

  • Rate limit information is written to stderr.

Examples

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.'