且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Microsoft Graph-授权流程-从控制台应用程序获取授权代码

更新时间:2023-10-06 12:03:34

HttpClient只会从login.microsoftonline.com返回用于登录的HTML,但无处可显示.HttpClient可以执行GET,POST等操作,但不是Web视图.

A HttpClient will only return the HTML for sign-in from login.microsoftonline.com, but will have nowhere to show it. The HttpClient can do GET, POST etc but is not a web view.

我从未测试过从控制台应用程序扩展Web视图的情况,因此我不确定是否可行.可以通过PowerShell完成此操作,但这与控制台应用程序不同.您可以检查一下.

I have never tested spinning up a webview from a Console app, so I'm not sure if it's possible. It can be done from PowerShell, but that is not the same as a Console app. You may check that out.

或者您可以让用户在控制台应用程序中输入用户名和密码,然后使用密码"授予类型流程获取访问令牌.不建议这样做,但有可能.您可以在此处阅读有关密码授予类型流程的更多信息:

Or you can let the user enter the username and password in the Console app and use the "password" grant type flow to obtain the access token. it's not recommend, but it's possible. You can read more about the password grant type flow here:

https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc