AZ给出了有线401错误 [英] AZ gives wired 401 error
问题描述
你好,
我的powershell脚本看起来像这样
$ SecurePw = ConvertTo-SecureString $ DeploymentServicePrincipalPassword -AsPlainText -Force
az login --service-principal -u $ DeploymentServicePrincipalId -p $ SecurePw --tenant $ TenantId
az account set - -subscription $ SubscriptionId
az cosmosdb collection update --collection-name $ CollectionName --name $ AccountName --db-name $ DBName --resource-group $ ResourceGroupName --throughput $ Throughput
当我运行它时,它会给我这个错误,但在此之后它会起作用。
获取令牌请求返回http错误:401和服务器响应:{"错误":" invalid_client"," error_description":" AADSTS50012:提供了无效的客户端密码。\ r \\ n nTrace ID:GUID \\ n相关ID:GUID \\ n时间戳:2019-01-30
03:59:07Z","error_codes":[50012]," timestamp"": & "; 2019-01-30 03:59:07Z"","trace_id":"GUID","correlation_id":"GUID"}
如果我没有将密码转换为安全字符串,那么它就可以了。如何修复以上脚本?
谢谢
您好 anonymous12348 ,
感谢您与我们联系!我们注意到同样的问题被问到了
here ,并提供了一个可能的解决方案:
SecurePw = ConvertTo-SecureString'< your secret>' - AsPlainText -Force
AzPass = [Runtime.InteropServices.Marshal] :: PtrToStringAuto([Runtime.InteropServices。元帅] :: SecureStringToBSTR(
Hi there,
My powershell script looks like this
$SecurePw = ConvertTo-SecureString $DeploymentServicePrincipalPassword -AsPlainText -Force
az login --service-principal -u $DeploymentServicePrincipalId -p $SecurePw --tenant $TenantId
az account set --subscription $SubscriptionId
az cosmosdb collection update --collection-name $CollectionName --name $AccountName --db-name $DBName --resource-group $ResourceGroupName --throughput $Throughput
when I run it, it gives me this error, but after that it works.
Get Token request returned http error: 401 and server response: {"error":"invalid_client","error_description":"AADSTS50012: Invalid client secret is provided.\r\nTrace ID: GUID\r\nCorrelation ID: GUID\r\nTimestamp: 2019-01-30 03:59:07Z","error_codes":[50012],"timestamp":"2019-01-30 03:59:07Z","trace_id":"GUID","correlation_id":"GUID"}
If I don't convert the password to secure string, then it just works fine. How can I fix above script?
Thanks
Hello anonymous12348,
Thanks for reaching out to us! We've noticed that the same question had been asked here, and a possible solution has been provided:
SecurePw = ConvertTo-SecureString '<your secret>' -AsPlainText -Force
AzPass = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR(
这篇关于AZ给出了有线401错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!