久久久久久久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 超時)
主站蜘蛛池模板: 国产精品一区久久久 | 天天操操| 欧美一区二区免费在线 | 国产精品免费一区二区三区 | 中文字幕在线免费视频 | 中文字幕成人在线 | 国产精品视频在线播放 | 亚洲一区二区三区观看 | 欧美日韩在线一区二区 | 91在线精品一区二区 | 91精品国产高清一区二区三区 | 国产精品免费一区二区三区四区 | 天天躁日日躁xxxxaaaa | 亚洲三区在线 | 欧美色欧美亚洲另类七区 | 国产日韩精品一区二区三区 | 久久久女女女女999久久 | 亚洲成av人片在线观看无码 | 久久久久久国产精品 | 国产精品18久久久久久白浆动漫 | 作爱视频免费观看 | a级免费观看视频 | 精品熟人一区二区三区四区 | 国产精品入口麻豆www | 手机在线不卡av | 精品在线一区 | 久久久精彩视频 | 国产高清在线精品 | 一区二区手机在线 | 青青草视频网 | 色综合中文 | 草久久久 | 成av在线| 午夜91| 欧美日韩大片 | 亚洲3级 | 午夜小电影 | 91xxx在线观看 | 国产一级特黄aaa大片评分 | 视频一区在线观看 | 在线国产欧美 |