簡體   English   中英

Azure B2C 移動應用程序與 web api 相結合

[英]Azure B2C mobile app in combination with a web api

我已經設置了一個 Azure B2C,我在其中配置了 B2C_1_sign_up_sign_in 用戶流。 此外,我添加了一個應用程序注冊,其中添加了移動和桌面應用程序平台。 這一切都很好,我可以驗證移動應用程序。 為此,我收到一個 ID 令牌。 我希望這個移動應用程序與 C# web api 通信。 這個 web api 應該能夠驗證令牌。 但是我需要一個訪問令牌。

api 配置如下:

services.AddMicrosoftIdentityWebAppAuthentication(Configuration, "AzureB2C");
services
    .AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
    .AddMicrosoftIdentityWebApi(
        options =>
        {
            Configuration.Bind("AzureB2C", options);
            options.TokenValidationParameters.NameClaimType = "name";
        },
        options =>
        {
            Configuration.Bind("AzureB2C", options);
        });

AzureB2C 具有以下設置:

  "AzureB2C": {
    "Instance": "https://login.microsoftonline.com/",
    "Domain": "[domain].onmicrosoft.com",
    "ClientId": "[clientId]",
    "TenantId": "[tenantId]"
  }

下一步要采取什么措施才能使這種情況發揮作用? 如何從移動應用程序中獲取可以在 web api 中驗證和使用的訪問令牌?

您需要為您的客戶端應用程序提供對 API 的訪問權限。 然后,您將獲得一個可在調用 API 時使用的訪問令牌。

https://docs.microsoft.com/en-us/azure/active-directory-b2c/add-web-api-application?tabs=app-reg-ga

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM