It's possible to authenticate yourself via the command line; there's no need to set up a website or so.
- Open the application page via https://stackapps.com/apps/oauth and make sure the option 'Enable Client Side OAuth Flow' is disabled.
- You can use any domain (e.g.
stackapps.com
) as OAuth domain; you don't need to control it.
- Open the following URL in your browser (add the actual client id from the application page, and the scope with what you actually need - for details, see the documentation):
https://stackoverflow.com/oauth?client_id=...&scope=read_inbox,no_expiry,write_access,private_info&redirect_uri=https://stackapps.com
- After authenticating, you'll get redirected to
https://stackapps.com/?code=...
; the code ends in ))
.
- Execute the following command in a terminal (add the client id and client secret from the application page and the code from the previous step):
curl -d "client_id=...&client_secret=...&code=...&redirect_uri=https://stackapps.com" -X POST https://stackoverflow.com/oauth/access_token
- The result is a simple
access_token=...
and the token also ends in ))
.
You can now use that token in combination with your app key, e.g. to read your global inbox with a GET call to https://api.stackexchange.com/2.3/inbox?key=...&access_token=...
.
Another option is provided here by @rene, but this one is (IMVHO, of course) simpler if you know how to handle the command line and/or you're not particularly fond of JavaScript.