I tried to use the Stack Exchange API to authenticate the user.
I have registered my app with redirect_uri
as stackexchange.com/oauth/login_success
.
But it always throws "redirect_uri is not a valid uri".
That error means either that you've misconfigured the app or that the authentication call is incorrect.
Note that stackexchange.com/oauth/login_success
is not a valid redirect_uri
irregardless.
You probably want/need to use Client side (Implicit) authentication, in which case the redirect_uri
would be:
https://stackexchange.com/oauth/login_success
Note the mandatory https://
.
Be sure your app is configured as shown in this answer.
Then you can use a URL like the following to authenticate:
https://stackexchange.com/oauth/dialog?client_id={YOUR CLIENT ID}&scope=no_expiry&redirect_uri=https://stackexchange.com/oauth/login_success
When you fetch that page, something like this will end up as the redirected-to URL:
https://stackexchange.com/oauth/login_success#access_token=wdR8Lm7m4ibD48lfrCcFxQ))&expires=86399
You would then use the access_token
to make an API query like:
https://api.stackexchange.com/2.2/questions/30028657/answers?site=stackoverflow&key=RoZwtHUrhMP088oVGCMlxA((&access_token=wdR8Lm7m4ibD48lfrCcFxQ))&filter=!)4k-FmUi-xgG3sdSdPz*cQNNqR0A
(Note that the example token, above, has long since been invalidated. Use your own values for it and for key
.)