TwistedOwl
TwistedOwl

Reputation: 1324

Get browser response or callback in node.js CLI

Snyk asks for authentication when user uses it on first time. It looks like this:

  1. User types snyk auth in cmd.
  2. Tab opens in browser with log in page.
  3. Log in.
  4. Snyk receives response that I have logged in and proceeds next.

1 - 3 is obvious for me how it works. But I don't understand how node knows that I have logged in. It has something to do with HTTP headers I guess but still I have no idea how it should look like in a code. I have tried to find my answer in cli/commands/auth.js but code is too complicated to me.

Upvotes: 2

Views: 395

Answers (1)

Kayvan Mazaheri
Kayvan Mazaheri

Reputation: 2597

You can create a temporary http server with a callback route for authentication; just like you do in a simple ordinary web application.
After the authentication, you can save the received information (e.g. in a file) and stop the http server.

Upvotes: 4

Related Questions