Redirecting to an Angular application with Token Bearer

Viewed 14

One of our devs is working with KeyCloak to grab an Authorization Token before redirecting to our Angular application.

Is it possible to even READ that token on the front end when our angular app bootstraps? Or do we need to go straight to the server in order to read that token?

For example, I can use Postman or reqbin.com (with Chrome extension) to make the GET request to my app.

But in terms of reading that auth bearer token on the front end - can it be done?

Sample GET request to login page:

    var url = "http://localhost:4200/#/login";

    var xhr = new XMLHttpRequest();
    xhr.open("GET", url);

    xhr.setRequestHeader("Authorization", "Bearer MyTestToken123");

    xhr.onreadystatechange = function () {
       if (xhr.readyState === 4) {
          console.log(xhr.status);
          console.log(xhr.responseText);
       }};

    xhr.send();

and I do get the SUCCESS message below.

enter image description here

Naturally we could send it via Query Params, but that is not desirable.

Any advice would be appreciated.

0 Answers
Related