Skip to main content
3 of 3
edited title
Glorfindel
  • 6.9k
  • 3
  • 22
  • 49

How to get access_token from the uri after the fetch function executes?

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?