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

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

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

問題描述

限時送ChatGPT賬號..

這個想法是讓它像 Azure Powershell 一樣工作,即彈出標準的 Active Directory 身份驗證對話框,我輸入我的憑據(jù),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模板網(wǎng)!

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

相關文檔推薦

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屋-程序員軟件開發(fā)技
.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做受 | 亚洲福利在线观看 | 国产精品污污视频 | 欧美日韩18| 夜夜骑首页 | 欧美日韩视频网站 | 日韩高清在线 | 91高清在线观看 | 日韩欧美国产精品一区二区三区 | 国产乱码精品一区二区三区中文 | 国产成人在线视频免费观看 | 91成人在线 | 污视频在线免费观看 | 一区二区日本 | 欧美成人免费在线 | 蜜臀久久 | 亚洲精品国产一区 | 亚洲劲爆av | 亚洲国产精品成人久久久 | 亚洲午夜精品久久久久久app | 亚洲精久久| 免费一区二区 | 日韩精品一区二区三区 | 一二区视频 | 北条麻妃国产九九九精品小说 | 日皮视频免费 | 天堂资源视频 | 91精品国产综合久久久动漫日韩 | 日韩精品一区二区三区老鸭窝 | 国产精品视频久久 | 日本精品久久久久久久 | 国产91av视频在线观看 | 精品国产91久久久久久 |