1

I am using this snippet to authorize to the Stack Exchange API

const baseUrl =
      "https://stackexchange.com/oauth/dialog?client_id=17823&scope=read_inbox,no_expiry&redirect_uri=https://stackexchange.com/oauth/login_success";
    export default class Authentication {
      authorize() {
        console.log("calling authorize");
        fetch(baseUrl, {
          headers: {
            "Content-Type": "application/x-www-form-urlencoded",
            "Access-Control-Allow-Origin": "https://stackexchange.com",
          },
          mode: "no-cors",
        });
      }
    }

It is not redirecting to the user's approval page. Instead when I open the response from the network tab, it takes me to this URI:

https://stackexchange.com/oauth/login_success#access_token=43w24pKEasZPWEiGljW(5Q))

which shows 'Authorizing Application'.

Can anyone help what's wrong with the flow?

1 Answer 1

1

As you can see, the access token is in the URL, it's 43w24pKEasZPWEiGljW(5Q)) (the trailing parentheses are part of it).

What you should probably do (unless you're just using the flow to get an access token for yourself) is to change the OAuth domain of your application in the settings here.

enter image description here

stackexchange.com is the default value, and you should point it to a website you have control over.

2
  • hey glorfindel, I have enabled client side flow but am unable to redirect to my localhost ,any solution
    – fuzious
    May 4, 2020 at 7:59
  • Perhaps; I'm mostly using server-side authentication. I would need some details though, so it's best to ask a question ...
    – Glorfindel
    May 4, 2020 at 8:04

You must log in to answer this question.

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