如何在 ADB2C 的 Restful 技术配置文件中使用动态 Bearer 令牌?

问题描述 投票:0回答:1

我有一个 API,可以使用 TTL 为 1 小时的不记名令牌访问该 API。我需要通过 ADB2C 使用这个 API。

根据 Microsoft 文档,不记名令牌是从策略密钥 B2C_1A_B2cRestClientAccessToken 中读取的:

<TechnicalProfile Id="REST-API-SignUp">
  <DisplayName>Validate user's input data and return loyaltyNumber claim</DisplayName>
  <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
  <Metadata>
    <Item Key="ServiceUrl">https://your-app-name.azurewebsites.NET/api/identity/signup</Item>
    <Item Key="AuthenticationType">Bearer</Item>
    <Item Key="SendClaimsIn">Body</Item>
  </Metadata>
  <CryptographicKeys>
    <Key Id="BearerAuthenticationToken" StorageReferenceId="B2C_1A_B2cRestClientAccessToken" />
  </CryptographicKeys>
</TechnicalProfile> 

但是,策略密钥 (B2C_1A_B2cRestClientAccessToken) 是静态的,而在我的例子中,每次 ADB2C 需要使用 API 时都需要检索不记名令牌。我该如何实现这个目标?

azure azure-active-directory azure-ad-b2c azure-ad-b2c-custom-policy
1个回答
-1
投票

下面的微软文档似乎解释了如何获取访问令牌并在每次需要使用API时使用。我还没有测试它,但它似乎完全被覆盖了:

https://learn.microsoft.com/en-us/azure/active-directory-b2c/secure-rest-api?tabs=windows&pivots=b2c-custom-policy#pre先决条件

© www.soinside.com 2019 - 2024. All rights reserved.