【发布时间】:2021-05-25 11:04:33
【问题描述】:
我正在使用 Azure Cloud PowerShell 通过使用获取访问令牌
$postParams = @{"client_id"="xxx3f7c-2a52-4be8-a7cf-1b499ee58d4d";
"scope"="https://graph.microsoft.com/.default";
"client_secret"="xxxL66S-h4pMnIPZrR7-..9L7NnyU9B4";
"grant_type"="client_credentials"
}
Invoke-WebRequest -Uri https://login.microsoftonline.com/xxxaab-164a-4603-b614-9405173c5351/oauth2/v2.0/token -Method POST -Body $postParams
但是,返回的标记被截断并替换为 ... 而没有结束内容属性的引号。
StatusCode : 200
StatusDescription : OK
Content : {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"eyJ0eXAiOiJKxxxiLCJub25jZSI6IlV3YTF4NWJYZnE2V3hOS211TFVqNEJYaTNIZGVKNExLeEZSSFMxVGs4eWsiLCJhbGciOiJSUzI1NiIsIng1dCI6Im5Pb…
RawContent : HTTP/1.1 200 OK
Cache-Control: no-store, no-cache
Pragma: no-cache
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
P3P: CP="DSP CUR OTPi IND OTRi ONL FIN…
Headers : {[Cache-Control, System.String[]], [Pragma, System.String[]], [Strict-Transport-Security, System.String[]], [X-Content-Type-Options, System.String[]], [P3P, System.String[]], [x-ms-request-id, System.String[]],
[x-ms-ests-server, System.String[]], [Set-Cookie, System.String[]], [Date, System.String[]], [Content-Type, System.String[]], [Expires, System.String[]], [Content-Length, System.String[]]}
Images : {}
InputFields : {}
Links : {}
RawContentLength : 1507
RelationLink : {}
内容属性以 m5Pb... 结尾,不完整。如何从 Azure Cloud PowerShell 获取完整的令牌内容?
【问题讨论】:
-
如果将请求保存到变量然后调用
Content属性,它是否仍然被截断?$req = Invoke-WebRequest -Uri http.....和$req.Content -
截断仅在输出中,只是因为它不适合显示。在
$req.Content | ConvertFrom-Json里面是完整的。 -
您好,您可以accept作为结束话题的答案。
标签: azure powershell oauth-2.0 azure-active-directory microsoft-graph-api