首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >即使使用OAuth帐户,也不能使用@tenant.onmicrosoft.com 2.0 ROPC (资源所有者密码凭据流)

即使使用OAuth帐户,也不能使用@tenant.onmicrosoft.com 2.0 ROPC (资源所有者密码凭据流)
EN

Stack Overflow用户
提问于 2022-07-29 13:16:38
回答 1查看 61关注 0票数 0

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

谁能指点我一下吗?

EN

回答 1

Stack Overflow用户

发布于 2022-07-30 20:08:18

您可能需要对请求体的参数进行URL编码。

试试下面的脚本:

代码语言:javascript
复制
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

$Authentication
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73167371

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档