Как получить заголовки из перенаправленного ответа с помощью window.open ()? - PullRequest
0 голосов
/ 20 мая 2019

Я работаю над модулем аутентификации. Я пытаюсь перейти по URL-адресу и перенаправить его на другой URL-адрес, который возвращает файлы cookie и заголовки. Как получить доступ к файлам cookie и заголовкам в угловом коде?

    let state_url = encodeURIComponent(window.location.href);


   let authUrl = "https://firsturl.com"+ "?parameter1="+"value"+"&redirect_uri="+"http://localhost:8085/auth"+"&response_type="+response_type + "&scope="+ scope_val + "&state="+ state_url;




    this.href = this.router.url;
    console.log("router url: "+this.router.url);

             try{
                this.tokenresponse = window.open(authUrl,'_self');
                console.log(" window href: "+window.location.href);
                localStorage.setItem("href",window.location.href);
                console.log("query path name: "+window.location.pathname);
                localStorage.setItem("querypathname",window.location.pathname);
                console.log("local storage get item: "+window.localStorage.getItem);

                console.log("window URL: "+window.URL.toString);

                console.log("search URLparams "+window.URLSearchParams.arguments);

                console.log("self session storage: "+window.self.sessionStorage.getItem.arguments);

                console.log(window.sessionStorage.getItem.arguments);



                var token = ""
                token = String(this.tokenresponse);
                localStorage.setItem("OIDCJwt",token);
                if(localStorage.getItem("OIDCJwt"))
                    console.log("token stored in local storage");
                else console.log("token not stored in local storage");



                if(!this.tokenresponse){
                     throw new Error('JWT Authentication call failed!');
                }
             }catch(e){
                 throw new Error('JWT Authentication call failed!');
             }
    }

}

}

'http://localhost:8085/auth' API возвращает URL следующим образом: «http://localhost:4200/null?auth=DHDJYTr675SKKKVR"

Я хочу извлечь токен аутентификации, т. Е. "DHDJYTr675SKKKVR"

Я попытался напечатать несколько параметров, но не повезло. Я также попытался выполнить метод window.open в режиме _blank. Это тоже не сработало.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...