Spotify redirect_uri to app

Hello,
I’m using the Authorization API provided by Spotify (https://developer.spotify.com/web-api/authorization-guide/) and inAppBrowser like this

    const browser = this.iab.create('https://accounts.spotify.com/authorize/?client_id='+client_id+"&response_type="+response_type+"&redirect_uri="+redirect_uri+"&state=34fFs29kd09&show_dialog=true","to _self","location=yes,toolbar=no");
    browser.show();

It’s work but i don’t want to redirect the user into the redirect_uri I just want to catch the code in the redirect_uri https://example.com/callback?code=“XXXXX” and go back to the app.

Is this possible ?

Thanks

Can you register any random url as callback?

const browser = window.cordova.InAppBrowser.open(
          url,
          "_blank",
          "location=yes,clearsessioncache=yes,clearcache=yes"
      );
      browser.addEventListener("loadstart", (event) => {
        if ((event.url).indexOf("http://localhost/callback") === 0) {

          browser.removeEventListener("exit", (event) => {});
          browser.close();

          // do stuff with URL
        }
      });
      browser.addEventListener("exit", function(evt) {
        reject("Sign in flow was canceled");
      });

Note that this doesn’t use Ionic Native.