Azure Cloud PowerShell return 输出已替换为点点
Azure Cloud PowerShell return output got replaced with dot dot dot
我正在使用 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 获取完整的令牌内容?
@Santiago Squarzon 说的对,你需要将请求保存到一个变量中,然后调用Content
属性,它会return 完整的访问令牌。
$postParams = @{"client_id"="ab717ac0-4abe-449d-aeb3-685c86c22xxx";
"scope"="https://graph.microsoft.com/.default";
"client_secret"="U5BPXYvLy2oO.5JE.Y.Ty3d~7b281W5xxx";
"grant_type"="client_credentials"
}
$req=Invoke-WebRequest -Uri https://login.microsoftonline.com/e4c9ab4e-bd27-40d5-8459-230ba2a757fb/oauth2/v2.0/token -Method POST -Body $postParams
$req.Content
我正在使用 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 获取完整的令牌内容?
@Santiago Squarzon 说的对,你需要将请求保存到一个变量中,然后调用Content
属性,它会return 完整的访问令牌。
$postParams = @{"client_id"="ab717ac0-4abe-449d-aeb3-685c86c22xxx";
"scope"="https://graph.microsoft.com/.default";
"client_secret"="U5BPXYvLy2oO.5JE.Y.Ty3d~7b281W5xxx";
"grant_type"="client_credentials"
}
$req=Invoke-WebRequest -Uri https://login.microsoftonline.com/e4c9ab4e-bd27-40d5-8459-230ba2a757fb/oauth2/v2.0/token -Method POST -Body $postParams
$req.Content