[英]Get Azure AD access token without client secret, username/password for Power BI from Angular
[英]Can you get an access token for Azure with a username and password and without using a client_id via web request?
场景:我正在尝试使用 web 请求获取访问令牌,因为我无法使用 Azure PowerShell。我正在尝试复制的情况是Get-AzAccessToken
,我已经使用我的用户名和密码进行了身份验证,但我没有提供client_id
。
我可以使用以下方法在 PowerShell 中获取访问令牌:
$postParams = @{
grant_type = 'password'
client_id = $ClientId
username = $Username
password = $Password
scope = 'https://graph.microsoft.com/.default'
}
Write-Host "Getting access token for app"
Invoke-RestMethod `
-Uri https://login.microsoftonline.com/$TenantId/oauth2/v2.0/token `
-Method POST `
-ContentType application/x-www-form-urlencoded `
-Body $postParams
我还可以使用 Azure PowerShell 命令Get-AzAccessToken
访问令牌。
是否可以在不使用 client_id 的情况下获取访问令牌? 如果不是,是Get-AzAccessToken
使用client_id
吗?
没有客户 ID 是不可能的。 是的,Azure PowerShell 正在使用一个。 实现这一点的最佳方法是注册您自己的应用程序并使用其客户端 ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.