2

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".

2

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.)

  • I am unable to give https:// in oauth domain field , it throws error saying port is not allowed in oauth domain – Kishorekumar E K Aug 14 '16 at 19:30
  • Use the setting as shown in this answer EXACTLY (Except for name and description). – Brock Adams Aug 14 '16 at 19:31
  • I should give stackexchange.com in app registeration and should give "stackexchange.com/oauth/login_success" while making the call. – Kishorekumar E K Aug 14 '16 at 19:52
  • 1
    Correct at last. :) – Brock Adams Aug 14 '16 at 19:54
  • I have done all this steps and now i want to authenticate using Stack Exchange API using login form. Can some one tell the steps how to do it?@BrockAdams – samson maben Aug 10 '17 at 5:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .