我有一个需要登录另一个应用程序的应用程序,该应用程序在url中返回了一些数据,
第一页打开新标签,第二页返回示例数据。
http://localhost:4200/?access_token=access_token?expires_in=expires_in?=username=username
在离子型中,我使用此代码
return new Promise(function (resolve, reject) {
const browserRef = window.cordova.InAppBrowser.open(url);
browserRef.addEventListener("loadstart", (event) => {
if ((event.url).indexOf("http://localhost:8100") === 0) {
browserRef.removeEventListener("exit", (event) => { });
browserRef.close();
const url = new URL(event.url);
const access_token = url.searchParams.get("access_token");
const expires_in = url.searchParams.get("expires_in");
const username = url.searchParams.get("username");
var parsedResponse = {
access_token: access_token,
expires_in: expires_in,
username: username
};
if (parsedResponse["access_token"] !== undefined && parsedResponse["access_token"] !== null) {
resolve(parsedResponse);
} else {
reject("Problem authenticating with api login");
}
}
});
browserRef.addEventListener("exit", function (event) {
reject("The sign in flow was canceled");
});
});
在角度上有类似的东西吗?