Sign up ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

I am trying to get a non-expiry access token, like so:{{some_uri}}&client_id={{some_value}}

I am repeatedly getting the error:

Application Login Failure
An error occurred while login into an application.

Error Details
error description: Cannot return to provided redirect_uri

I have tried several values for `redirect_uri, such as:

  • 10.**.**.**/myscript.php

None of them seem to be working.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Refer to the Stack Exchange API, Authentication docs. It looks like you are trying to authenticate using either a server you do not control, or a local server that is not on the public internet.

Crucial Points:

  1. Do not specify a redirect_uri to any server that you do not control!!!
    When you use something like redirect_uri=, then a third party host has you, or your user's, credentials! That page/server will see a request like:

    It can then use that access_token to do unspeakable evil.

    This is a major breach of both security and trust! (Frankly, if you or your app are caught doing this, lifetime bans should be issued. Legal action may even be appropriate in some cases.)

  2. The value you set for OAuth Domain must match the redirect_uri.

    So, if you use, redirect_uri=,
    then you must set OAuth Domain to

  3. If you do not have your own server:

    1. Use the "implicit OAuth 2.0 flow" (Client side). Activate Enable Client Side OAuth Flow in your app's control panel.
    2. Leave Disable Desktop Application OAuth Redirect Uri unchecked.
    3. Set OAuth Domain to
    4. Use redirect_uri=

  4. Be sure to use GET requests for implicit (client side) OAuth and POST for explicit (server-side) OAuth.

When the authentication is successful, the access_token will be in the location.hash of the redirected page. For example:
share|improve this answer
So i just need security token for one time. Instagram/Facebook use any redirect_uri and provide token on the URL itself. StackApps following the same model, i was expecting that any URL should work. Will try the point 2/3 and will update. Thanks for answering. –  user34257 Aug 14 at 4:18
The token is returned in the URL (hash). And, even for Instagram/Facebook it's a major security breach to use a 3rd-party URL. –  Brock Adams Aug 14 at 4:25

You must log in to answer this question.

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