Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Improve the CLI auth logic #226

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ankon
Copy link
Contributor

@ankon ankon commented Feb 3, 2016

These are changes I needed for creating a desktop application using this library:

  1. Provide client_id, client_secret, note, note_url, and fingerprint in the authorization request
  2. Allow reusing an existing authorization

There is still one open issue here: github will return a hashed token and the last 8 characters when reusing a token, but these values are not provided to the callback, so the app cannot actually verify the token. I'll open a separate issue for that, as it might need incompatible changes to the API.

This adds the ability to use client_id, client_secret, fingerprint, note, and note_url
fields in the authorization request.

See https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization
The `login` method will send a request to potentially reuse an existing
authorization when the auth config contains the `reuse` field with the value `true`
and the `id` field with the client id.

If no authorization is available, a new one will be returned in the `token` callback
parameter, otherwise the `token` callback parameter will be empty, and the caller
is assumed to know the token.
client_secret: @options.secret
fingerprint: @options.fingerprint
note: @options.note
note_url: @options.note_url
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the above 5 properties only if they exist in @options.

@pksunkara
Copy link
Owner

Just a few comments which need to be addressed.

@pksunkara
Copy link
Owner

@ankon Any update on this?

@pksunkara
Copy link
Owner

@ankon Could you give an update on this?

body: scopes,
url: url.parse(authorizationUrl),
method: authorizationMethod,
body: JSON.stringify({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls use json: true instead of JSON.stringify
ex.

 
       body: {
          scopes: scopes,
          client_id: this.options.id,
          client_secret: this.options.secret,
          fingerprint: this.options.fingerprint,
          note: this.options.note,
          note_url: this.options.note_url
       },
       json: true

@@ -81,7 +92,7 @@
err = _error;
callback(new Error('Unable to parse body'));
}
if (res.statusCode === 201) {
if ((ref = res.statusCode) === 200 || ref === 201) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls dont assign variable in if statement
its implicit

@ankon
Copy link
Contributor Author

ankon commented May 19, 2017

Oops, missed this. :/

I'm no longer using this library, so right now can not do any updates.

Copy link

@Aboodi19900 Aboodi19900 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repository owner locked and limited conversation to collaborators Mar 21, 2019
Repository owner unlocked this conversation Jun 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants