我正在尝试从 url 中提取字符串。我正在使用 vuejs,但无法使用路由器,因为该页面是 AWS Cognito OIDC 登录返回的回调 url。
网址如下所示:
http://localhost:8080/callback#id_token=eyJ...&access_token=eyJ...&expires_in=3600&token_type=Bearer&state=xxx
如果有解决方案让 vue 路由器处理哈希符号以便我可以使用,那很好:
this.$route.query.id_token
目前我使用以下方法检索令牌:
const matches = this.url.match(/(?<==).*(?=&acc)/i);
仅 Chrome 支持。它检索 '=' 字符和字符串 '&acc' 之间的任何内容。对于我想做的事情, id_token 或 access_token 是等价的。
如何在没有后视的情况下获得令牌字符串?
