密码修改后Powershell的认证问题



最近更改密码后,我无法执行"地形计划"。操作(或任何其他需要对Azure订阅进行身份验证的操作)。我实际上怀疑这是一个更合适的Azure AD问题,但决定先在Terraform区域询问,以防有人遇到这个问题(谷歌搜索了多个变体,但没有确定的Powershell情况)

错误信息是:

│ Error: building account: getting authenticated object ID: Error parsing json result from the Azure CLI: Error waiting for the Azure CLI: exit status 1: ERROR: AADSTS50173: The provided grant has expired due to it being revoked, a fresh auth token is needed. The user might have changed or reset their password. The grant was issued on '2021-09-20T19:11:35.3441875Z' and the TokensValidFrom date (before which tokens are not valid) for this user is '2021-10-11T21:32:17.0000000Z'.
│ Trace ID: <GUID>
│ Correlation ID: <GUID>
│ Timestamp: 2021-10-11 23:41:09Z
│ To re-authenticate, please run:
│ az login --scope https://graph.windows.net//.default
│
│ with module.policyset_definitions.provider["registry.terraform.io/hashicorp/azurerm"],
│ on modulespolicyset-definitionsmain.tf line 1, in provider "azurerm":
│ 1: provider "azurerm" {

跟踪、关联和时间戳当然因尝试而异。

我尝试:

Clear-AzContext
Clear-AzDefault
exit Powershell

(甚至重新启动,因为这已经发生了几天,我下班后关闭)然后再次登录。

我也试过了:

$c = Get-AzContext
Remove-AzContext -InputObject $c

与Azure Shell最接近的Powershell "az login——scope https://graph.windows.net//.default"似乎是:

Connect-AzAccount -AuthScope https://management.azure.com/

这并没有改变任何错误-仍然发生,仍然报告与上次发布令牌相同的时间。

由于问题似乎与我的令牌和与之关联的授权有关,因此我决定尝试通过以下方式强制刷新授权:

Connect-AzureAD
Get-AzureADUser -SearchString "<AzureADEmailAccount>"
Revoke-AzureADUserAllRefreshToken -ObjectId <GUID>

结果是我怀疑这是AAD问题的原因之一,而不是Terraform;错误信息没有改变,但是"grant"中报告的时间是在"grant"中发布的。从我修改密码的时间到我运行Revoke-AzureADUserAllRefreshToken的时间。

有什么建议吗?我也要试着联系微软,但想从这里开始,得到一个公开的答案。

我无法从Powershell获得Token刷新。

在微软支持的建议下,我安装了Azure CLI(必须努力获得管理权限才能这样做,这就是我以前没有尝试的原因),所以我可以做以下事情:

az login --use-device-code

这就解决了问题。

最新更新