如何从 URL 获取 token?

发布于 2025-01-17 03:54:13 字数 160 浏览 4 评论 0 原文

我的 ADB2C 创建的登录页面在身份验证成功后重定向到 SPA,并且在重定向 URL 中具有访问令牌作为 URL 参数。 首先,我想从 URL 中提取访问令牌。这可能吗? 其次,我想将提取的访问令牌存储在本地存储中。这也可以吗? 一旦这两个到位,我希望 SPA 能够使用访问令牌访问后端 API。 谢谢。

My ADB2C created login page redirects to SPA after successful authentication and has an access token as URL parameter in the redirect URL.
First, I want to extract an access token from a URL. Is this possible?
And second, I want to store the extracted access token in localstorage. Is this also possible?
Once these two are in place, I would expect the SPA to be able to access the backend API using an access token.
thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长发绾君心 2025-01-24 03:54:13

要从 URL 获取访问令牌,请使用 邮递员

  • 在 Postman、Open & 中切换到授权选项卡
  • 类型下拉列表
  • 中选择OAuth 2.0在授权类型下拉列表中,选择授权代码
  • 在回调 Url 中,输入您的重定向 Url
  • 在 Auth Url 中,输入您的授权
  • Url访问令牌 Url,输入您的令牌 Url
  • 输入您的客户端 ID 并输入范围。
  • 单击获取新访问令牌按钮。
  • 这将生成访问令牌。

有关更多详细信息,请参阅这些链接:

在 POSTMAN (vmsdurano.com) 中使用 OAuth2.0 授权代码和 PKCE 从 Azure B2C 获取访问令牌

在Postman中请求Azure AD B2C的访问令牌 - 堆栈内存溢出一个>。

To get access token from URL make use of Postman.

  • In Postman, Open & switch to Authorization tab
  • Select OAuth 2.0 from the Type dropdown
  • In Grant type dropdown, select Authorization Code
  • In callback Url, enter your redirect Url
  • In Auth Url, enter your Authorize Url
  • In Access toke Url, enter your token Url
  • Enter your client ID and enter scope.
  • click the Get New Access Token button.
  • And this will generate access token.

For more in detail, please refer these links:

Obtaining an Access Token from Azure B2C using OAuth2.0 Authorization Code with PKCE in POSTMAN (vmsdurano.com).

Request Access Token in Postman for Azure AD B2C - Stack Overflow.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文