Can I use OAuth if my app isn't running on a server?

169 Views Asked by At

I am making an application that works from the command line, and run locally on my computer. I want to be able to share it with other people, and thus are trying to apply OAuth. Do I need a server for the callback? If yes, can I just create it for a second, get the response, and close it?

Thanks

1

There are 1 best solutions below

1
erwinv On

According to Okta, yes, you need to spin up a temporary HTTP server:

The Trick to OAuth 2.0 on the Command Line

The way we’re going to avoid the need to copy and paste anything during the login flow is by having our PHP command line script start a mini HTTP server just when we need it, and shut down when we’re done.

The script will launch the browser to the authorization URL, and when Okta redirects the user back to the mini built-in server, we’ll catch that response, extract the authorization code, shut down the server, and continue with whatever the script was doing.

The example is in PHP, but the idea should also apply to Python.