久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 ADAL 對 Azure API 應用進行身份驗證

Authenticate to Azure API App using ADAL(使用 ADAL 對 Azure API 應用進行身份驗證)
本文介紹了使用 ADAL 對 Azure API 應用進行身份驗證的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有一個標記為公共(經過身份驗證)"的 Azure API 應用程序,并在相關網關中設置了 Azure Active Directory 身份,詳細信息請參見 保護 API 應用.

I have an Azure API App marked as "Public (authenticated)" and set up an Azure Active Directory identity in the associated gateway as detailed in Protect an API App.

然后我在同一個 Azure Active Directory 租戶中創建了一個本機應用程序,并在委派權限中添加了訪問網關的權限.

I then created a native application in the same Azure Active Directory Tenant and added permission to access the Gateway in the delegated permissions.

使用 ADAL 和以下代碼,我能夠成功地進行身份驗證并獲得訪問令牌,但我不知道如何使用它來訪問我的 API 應用程序.

Using ADAL and the following code, I'm able to successfully authenticate and get an access token, but I can't figure out how to use it to access my API app.

string Tenant = "[xxx].onmicrosoft.com";
string Authority = "https://login.microsoftonline.com/" + Tenant;
string GatewayLoginUrl = "https://[gateway].azurewebsites.net/login/aad";
string ClientId = "[native client id]";
Uri RedirectUri = new Uri("[native client redirect url]");

async Task<string> GetTokenAsync()
{
  AuthenticationContext context = new AuthenticationContext(Authority);
  PlatformParameters platformParams = new PlatformParameters(PromptBehavior.Auto, null);
  AuthenticationResult result = await context.AcquireTokenAsync(GatewayLoginUrl, ClientId, RedirectUri, platformParams);

  return result.AccessToken;
}

我已經手動輸入了一個 x-zumo-auth 標頭 測試了 API 應用程序,我進入了 Chrome,然后它就可以工作了,但是我使用 ADAL 獲得的令牌卻沒有.我還嘗試了他們的 示例代碼可以工作,但沒有給我刷新令牌.

I've tested the API app manually entering an x-zumo-auth header I get in Chrome and it works then, but not with a token I get using ADAL. I've also tried the browser forms described in their sample code which works but doesn't give me a refresh token.

我需要如何設置我的身份驗證代碼,以便我可以在我的 API 應用程序中使用 TokenCache 和 ADAL?

How do I need to set up my authentication code so I can use a TokenCache and ADAL with my API app?

推薦答案

您可能希望使用 AppServiceClient 對用戶進行身份驗證并調用受保護的 API 應用端點.將 Microsoft.Azure.AppService SDK (-pre) Nuget 包安裝到您的客戶端項目.

You may want to use AppServiceClient to authenticate the user and invoke a protected API App endpoint. Install Microsoft.Azure.AppService SDK (-pre) Nuget package to your client project.

您可以在 GitHub 上的 AzureCards 示例中找到更多詳細信息 - https://github.com/Azure-Samples/API-Apps-DotNet-AzureCards-Sample

You can find more details in the AzureCards samples on GitHub - https://github.com/Azure-Samples/API-Apps-DotNet-AzureCards-Sample

這篇關于使用 ADAL 對 Azure API 應用進行身份驗證的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 成人欧美日韩 | 特级淫片aaaaaaa级 | 亚洲一级二级三级 | 中文字字幕在线中文 | 久色精品| 成人午夜在线观看 | 一区二区三区av | 香蕉成人网 | 久久精品一区二区三区不卡牛牛 | 国产视频99 | 精品免费在线 | 中文字幕永久在线 | 成年人免费看片 | 黄网站免费看 | 日韩一区二区三区四区 | 日本久久视频 | 黄色大片免费在线观看 | 亚洲最大黄色网址 | 成人理论影院 | 97国产精品视频 | 国产精品久久久久久久久久久久久久 | 成人免费视频国产免费 | 欧美专区第一页 | 日韩毛片网站 | 黄色大片在线免费观看 | av福利在线 | 伊人国产女 | 视频在线观看一区 | 亚洲激情久久 | 欧美精品三区 | 亚洲天堂免费 | 91超碰人人 | 日韩色黄大片 | 99久久精品国产一区二区三区 | 狠狠干夜夜 | 麻豆一级片 | 美利坚合众国av | 亚洲亚洲人成综合网络 | 中文字幕免费高清 | a在线播放 | 伊人亚洲|