我正在开发身份验证模块。我正在尝试点击一个URL,并将其重定向到另一个返回cookie和标题的URL。如何使用角度代码访问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返回网址,如下所示: “ http://localhost:4200/null?auth=DHDJYTr675SKKKVR”
我要提取身份验证令牌,即:“ DHDJYTr675SKKKVR”
我尝试打印多个参数,但是没有运气。我也尝试过在“ _blank”模式下执行window.open方法。那个也不起作用。