git-token / cli

GitToken CLI Program
2 stars 0 forks source link

Handle 401 Authorization Error #8

Closed Ryanmtate closed 7 years ago

Ryanmtate commented 7 years ago
response:
   { status: 401,
     statusText: 'Unauthorized',
     headers:
      { date: 'Thu, 21 Sep 2017 22:11:14 GMT',
        'content-type': 'application/json; charset=utf-8',
        'content-length': '83',
        connection: 'close',
        server: 'GitHub.com',
        status: '401 Unauthorized',
        'x-github-media-type': 'github.v3; format=json',
        'x-ratelimit-limit': '60',
        'x-ratelimit-remaining': '59',
        'x-ratelimit-reset': '1506035474',
        'access-control-expose-headers': 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval',
        'access-control-allow-origin': '*',
        'content-security-policy': 'default-src \'none\'',
        'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
        'x-content-type-options': 'nosniff',
        'x-frame-options': 'deny',
        'x-xss-protection': '1; mode=block',
        'x-runtime-rack': '0.010214',
        'x-github-request-id': <redacted> },

Should respond with something a little more friendly, like:

Authorization Failed. Invalid GitHub Authorization Token.
Ryanmtate commented 7 years ago

https://github.com/git-token/cli/blob/master/src/register/index.js#L109

Catches 401 error and re-enters the program.