gpt4 book ai didi

AngularJS:如何清除URL中的查询参数?

转载 作者:行者123 更新时间:2023-12-03 04:28:01 24 4
gpt4 key购买 nike

我的 AngularJS 应用程序需要访问用户的 LinkedIn 个人资料。为了做到这一点,我需要将用户重定向到一个 LinkedIn URL,其中包含一个回调redirect_uri参数,该参数将告诉 LinkedIn 将用户重定向回我的 web 应用程序,并在 URL 中包含一个“code”查询参数。这是传统的 Oauth 2.0 流程。

一切都很好,除了 LinkedIn 将用户重定向回以下 URL:

http://localhost:8080/?code=XXX&state=YYY#/users/123/providers/LinkedIn/social-sites

我想从 URL 中删除 ?code=XXX&state=YYY 以使其干净。用户不需要查看我从 LinkedIn 重定向收到的查询参数。

我尝试了 $location.absUrl($location.path() + $location.hash()).replace(),但它将查询参数保留在 URL 中。

我也无法提取查询参数,例如“代码”,使用 ($location.search()).code。好像有?上面 URL 中的 # 之前是在欺骗 Angular。

最佳答案

我用

$location.search('key', null)

因为这不仅会删除我的 key ,还会将其从 URL 上的可见性中删除。

关于AngularJS:如何清除URL中的查询参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17376416/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com