簡體   English   中英

如何使用受B2C保護的Web API授權計划任務?

[英]How to Authorize a Scheduled Task with a B2C protected Web API?

我在Azure上托管了受B2C保護的Web API。 我需要創建一個計划任務(或Web服務),這將需要消耗Web Api的資源。 建議使用什么方法使計划任務通過Web Api進行身份驗證?

我認為我無法在這種情況下使用B2C。 我當時在考慮使用秘密密鑰,但我還不太清楚如何在Azure中進行設置以及如何更新Web Api OWIN中間件以同時處理B2C和密鑰身份驗證。

這是我當前的Startup.Auth:

    public void ConfigureAuth(IAppBuilder app)
    {
        TokenValidationParameters tvps = new TokenValidationParameters
        {
            // Accept only those tokens where the audience of the token is equal to the client ID of this app
            ValidAudience = ClientId,
            AuthenticationType = Startup.DefaultPolicy
        };
        app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions
        {
            // This SecurityTokenProvider fetches the Azure AD B2C metadata & signing keys from the OpenIDConnect metadata endpoint
            AccessTokenFormat = new JwtFormat(tvps, new OpenIdConnectCachingSecurityTokenProvider(String.Format(AadInstance, Tenant, DefaultPolicy)))
        });
    }

干杯!

您可以使用資源所有者密碼憑據(ROPC)用戶流

https://docs.microsoft.com/en-us/azure/active-directory-b2c/configure-ropc

暫無
暫無

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

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