久久久久久久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 超時)
主站蜘蛛池模板: 亚洲啪啪 | 久草资源在线 | 欧美狠狠操 | 国产成人精品999在线观看 | 九九热免费视频在线观看 | 国产最好的av国产大片 | 综合久久一区 | 男人天堂手机在线视频 | 日韩中文电影 | 日韩在线| www.色.com| 在线高清免费观看视频 | 久久中文字幕av | 久久免费观看视频 | 亚洲国产一区二区视频 | 亚洲成人毛片 | 国产成人在线一区 | 亚洲人成一区二区三区性色 | www在线| 国产精品一区二区不卡 | 国产第一页在线观看 | 草b视频| 亚洲精品电影网在线观看 | 狠狠草视频 | 国内精品久久精品 | 日韩波多野结衣 | 三级在线免费观看 | www.9191.com | 成年无码av片在线 | 日屁视频| 91免费电影| 99精品一级欧美片免费播放 | 精品国产乱码久久久久久久久 | 日韩a v在线免费观看 | 99r在线 | 国产小视频在线看 | 日韩网站在线观看 | 日韩久草 | 国产激情一区二区三区 | 国产乱码精品一区二区三区忘忧草 | 成人影院一区二区三区 |