0

I came across StackExchange API V2 unread notifications method and though of creating a small cli script which on execution will give me the unread notification count. Now, according to the docs this method requires authentication(access token) to fetch the data.

After reading authentication docs I found that one needs certain parameters like client_id to complete the implicit OAuth 2.0 flow.

I tried registering app at stackapps.com but it requires OAuth Domain, Application Website which I don't have.

So, what is the simplest way to get access_token to read users inbox for unread notification count.

CodesInChaos
  • 106,488
  • 23
  • 218
  • 262
RanRag
  • 48,359
  • 38
  • 114
  • 167

1 Answers1

0

Below is dirty one but you can try it

Say you have registered application at stackOverflow , With some dummy OAuth Domain = abc.com

where YR_REDIRECT_URL will be like http://myurl.abc.com

  • It will redirect to URL like below with some code.

    YR_REDIRECT_URL/?code=SOME_CODE

  • Get the code from redirected URL and form the POST request

    https://stackexchange.com/oauth/access_token?client_id=YR_CLIENT_ID&scope=no_expiry,read_inbox,private_info&redirect_uri=YR_REDIRECT_URL&client_secret=YR_CLIENT_SECRET&code=SOME_CODE

  • Then you will get response like below

    access_token=YR_ACCESS_TOKEN

You can use generated access_token(along with application key) with no_expiry (as generated with scope=no_expiry)

Sanjiv
  • 1,795
  • 1
  • 29
  • 45