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

是否可以將 AzureAD 身份驗證與控制臺應用程序一

Is it possible to use AzureAD authentication with a console application?(是否可以將 AzureAD 身份驗證與控制臺應用程序一起使用?)
本文介紹了是否可以將 AzureAD 身份驗證與控制臺應用程序一起使用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

這個想法是讓它像 Azure Powershell 一樣工作,即彈出標準的 Active Directory 身份驗證對話框,我輸入我的憑據,AzureAD 完成它的工作,然后控制臺應用程序無法訪問某個 Web 服務.

The idea is to make it work like Azure Powershell, i.e. the standard Active Directory authentication dialog pops up, I enter my credentials, AzureAD does its thing and then the console application cann access a certain webservice.

這可能嗎?應該沒那么難,但我找不到例子.

Is this possible? It shouldn't be that hard but I could find no example.

查看 WPF 示例,我看到它在 app.config 中設置了一個客戶端 ID.這真的有必要嗎?我的意思是,單頁 js 應用也沒有向 AD 注冊,是嗎?

Looking at the WPF example, I see it sets a client id in the app.config. Is this really necessary? I mean, a single page js app isn't registered with the AD either, is it?

推薦答案

事實上,任何客戶端應用程序都應該在 AAD 中注冊.

In fact, any client application should be regsitered in AAD.

控制臺應用程序也必須在 Azure AD 中注冊,因此您將擁有客戶端 ID 和客戶端重定向 URL,但沒有客戶端密碼.那么下面的代碼應該可以工作了:

Console app must be registered in Azure AD too, so you'll have client id and client redirect url, but no client secret. Then the following code should work:

void Main()
{
    var clientId = "client-GUID";
    var clientUrl = new Uri("redirect-url");  //can be anything starting with localhost
    var tenant = "name of your AAD tenant";
    string authority = "https://login.windows.net/" + tenant;

    string resource = "https://outlook.office365.com";  ///put id or url of resource you're accessing

    AuthenticationContext authenticationContext = new AuthenticationContext(authority, false);

    Console.WriteLine("Trying to acquire token");

    var pp = new PlatformParameters(PromptBehavior.Auto); //this brings web prompt
    var token = authenticationContext.AcquireTokenAsync(resource, clientId, clientUrl, pp, UserIdentifier.AnyUser).Result;
    Console.WriteLine("Got the token: {0}", token.AccessToken);
}

這篇關于是否可以將 AzureAD 身份驗證與控制臺應用程序一起使用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 超時)
主站蜘蛛池模板: 久久高清 | 日韩免费毛片 | av日韩在线播放 | 干干干日日日 | 亚洲精品66| 又爽又黄axxx片免费观看 | 91精品国产色综合久久不卡98 | 亚洲不卡在线观看 | 久草色播| 国产97视频在线观看 | av网站免费在线观看 | 国产精品美女久久久久久久久久久 | 亚洲一区二区三区四区视频 | 欧美福利| 91在线免费视频 | 一级做a爰片性色毛片16 | 欧美成人一区二区三区 | 久草在线在线精品观看 | 国产精品日本一区二区在线播放 | 一区二区精品 | 成人免费淫片aa视频免费 | 在线观看视频91 | 亚洲一区二区视频 | 国产精品久久久久久久久久久久久 | 精品久久久一区二区 | 亚洲成人免费av | 亚洲一区二区三区四区av | 亚洲免费一区二区 | 爱高潮www亚洲精品 中文字幕免费视频 | 国产精品美女www爽爽爽 | 国产h在线 | 在线日韩av电影 | 久久亚洲一区二区三区四区 | 国产欧美日韩一区二区三区在线 | av中文字幕在线播放 | 亚洲精品女人久久久 | 国产999精品久久久久久绿帽 | 成人免费在线播放视频 | 日日碰狠狠躁久久躁婷婷 | 中文字幕欧美一区 | 国产一区二区在线免费观看 |