Azure 是否可以使用MS Graph REST API在代码中登录用户并获取身份验证令牌?

Azure 是否可以使用MS Graph REST API在代码中登录用户并获取身份验证令牌?,azure,azure-active-directory,Azure,Azure Active Directory,我真的很想要这样的东西:它曾经在3.9版中工作,但现在不行了 具体而言: AcquireTokenAsync(todoListResourceId、clientId、uc) 那么,可以使用RESTAPI做同样的事情吗 这是一个功能测试,所以我们不能允许用户正常登录。我需要复制用户登录后看到的内容。是。可以使用HTTP请求直接为资源所有者密码凭据流获取令牌 我们可以使用Fiddler捕获请求,以查看所需的详细参数。下面是使用此流获取本机客户端应用程序访问令牌的代码示例: string resrou

我真的很想要这样的东西:它曾经在3.9版中工作,但现在不行了

具体而言: AcquireTokenAsync(todoListResourceId、clientId、uc)

那么,可以使用RESTAPI做同样的事情吗


这是一个功能测试,所以我们不能允许用户正常登录。我需要复制用户登录后看到的内容。

是。可以使用HTTP请求直接为资源所有者密码凭据流获取令牌

我们可以使用Fiddler捕获请求,以查看所需的详细参数。下面是使用此流获取本机客户端应用程序访问令牌的代码示例:

string resrouce = "https://graph.windows.net";
string clientId = "";
string userName = "";
string password = "";

HttpClient client = new HttpClient();  
string body = String.Format("resource={0}&client_id={1}&grant_type=password&username={2}&password={3}", Uri.EscapeDataString(resrouce), clientId, Uri.EscapeDataString(userName), Uri.EscapeDataString(password));
StringContent sc = new StringContent(body,Encoding.UTF8, "application/x-www-form-urlencoded");
var resoult= client.PostAsync("https://login.microsoftonline.com/xxxx.onmicrosoft.com/oauth2/token", sc).Result.Content.ReadAsStringAsync().Result;
如果您正在使用web app,我们需要在正文中附加
client\u secret
参数。

类似这样的内容:?