0

in stackoverflow(stackexchange api, https://api.stackexchange.com/docs/authentication) it clearly mentioned about how to send user to the login page and get access token from it, but the details for accessing user data by using url and parameters is not available , please help me to find that way to get user data from stackoverflow with correct url and parameters,

1.Send a user to https://stackexchange.com/oauth, with these query string parameters

client_id
scope (details)
redirect_uri - must be under an apps registered domain
state - optional

2.POST (application/x-www-form-urlencoded) the following parameters to https://stackexchange.com/oauth/access_token

client_id
client_secret
code - from the previous step
redirect_uri - must be the same as the provided in the first step

But the url and parameters to get user data by using this access token is not available ,

radhakrishnan
  • 1,399
  • 1
  • 14
  • 20

1 Answers1

0

You are right, the endpoints are not documented very well.

I would strongly suggest to take a look at the API explorer. e.g. For user info of "me": https://api.stackexchange.com/docs/me#order=desc&sort=reputation&filter=!9buxV.Gp.&site=stackoverflow&access_token=YOUROWNACCESSTOKEN&key=YOURAPIKEYIDONTKNOWWHY

  1. Click "Get Token" (it seems you already have your access token, just for the Explorer)

  2. Click "Run" : You can debug the request in the "network" tab of your browser console (e.g. in Safari: right mouse click / copy as curl to know what's really going on)

--> The problem with the stackexchange API is that it does NOT seem to work to send a
Bearer TOKEN - instead you (and the API explorer) send the access_token as a GET parameter :

https://api.stackexchange.com/2.2/me?order=desc&sort=reputation&filter=withbody&site=stackoverflow&access_token=YOUROWNACCESSTOKEN&key=YOURAPIKEYIDONTKNOWWHY

The site parameter selects which profile of the StackExchange network you want.

[{"site":"http://stackoverflow.com","param":"stackoverflow"},{"site":"http://serverfault.com","param":"serverfault"},
{"site":"http://superuser.com","param":"superuser"},{"site":"http://webapps.stackexchange.com","param":"webapps"},
{"site":"http://gaming.stackexchange.com","param":"gaming"},{"site":"http://webmasters.stackexchange.com","param":"webmasters"},
{"site":"http://cooking.stackexchange.com","param":"cooking"},{"site":"http://gamedev.stackexchange.com","param":"gamedev"},
{"site":"http://photo.stackexchange.com","param":"photo"},{"site":"http://stats.stackexchange.com","param":"stats"},
{"site":"http://math.stackexchange.com","param":"math"},{"site":"http://diy.stackexchange.com","param":"diy"},
{"site":"http://gis.stackexchange.com","param":"gis"},{"site":"http://tex.stackexchange.com","param":"tex"},
{"site":"http://askubuntu.com","param":"askubuntu"}]
sebilasse
  • 4,278
  • 2
  • 37
  • 36