我想我仔细地遵循了下面的文档,但我仍然不能使用ROPC,即使是使用@tenant.onmicrosoft.com帐户。https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc
谁能指点我一下吗?

发布于 2022-07-30 20:08:18
您可能需要对请求体的参数进行URL编码。
试试下面的脚本:
Add-Type -AssemblyName System.Web
$client_id = [System.Web.HttpUtility]::UrlEncode("<client_id>")
$client_secret = [System.Web.HttpUtility]::UrlEncode("<client_secret>")
$tenant = [System.Web.HttpUtility]::UrlEncode("<tenant_id>")
$user = [System.Web.HttpUtility]::UrlEncode("<user>")
$password = [System.Web.HttpUtility]::UrlEncode("<user_password>")
$scopes = [System.Web.HttpUtility]::UrlEncode("<scopes>")
$AuthUri = "https://login.microsoftonline.com/$tenant/oauth2/v2.0/token"
$AuthBody = "grant_type=password&client_id=$client_id&client_secret=$client_secret&username=$user&scope=$scopes&password=$password"
$Authentication =
Invoke-RestMethod -Method Post `
-ContentType application/x-www-form-urlencoded `
-Uri $AuthUri `
-Body $AuthBody
$Authenticationhttps://stackoverflow.com/questions/73167371
复制相似问题