mootari / observable-client

MIT License
14 stars 6 forks source link

Fix: auth process no longer matches Observable and Github #3

Closed mootari closed 4 years ago

mootari commented 4 years ago

Fixes #2

Fil commented 4 years ago

with backup.js:

const {RestClient, AuthGithubPrompt} = require('observable-client');

const client = new RestClient;
(async () => {
  await new AuthGithubPrompt(client, {
    clientId: '1a8619df27715d9d2c97',
    loginName: 'fil',
  }).authorize();

  console.log('authorized', (await client.get('/user')).body);
})();
❯ /usr/local/Cellar/node/14.8.0/bin/node backup.js
(node:45907) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
✔ GitHub password … *********
✔ GitHub 2FA Token … 000000
(node:45907) UnhandledPromiseRejectionWarning: Error: Unprocessable Entity
    at Request.callback (/Users/fil/Source/observable/backup/node_modules/superagent/lib/node/index.js:804:15)
    at IncomingMessage.<anonymous> (/Users/fil/Source/observable/backup/node_modules/superagent/lib/node/index.js:1036:18)
mootari commented 4 years ago

The auth process is probably the same for 2FA tokens and device codes, and fixing one will likely fix the other.

mootari commented 4 years ago

I just force-pushed a fix (authenticity token was taken from the wrong form). It works for device verification, and the problem with 2FA was very likely the same. Can you please give it another try?

Fil commented 4 years ago

Yes! Merci 🙏