$TOKEN变量值在传递到标头后会发生变化。如何才能使$TOKEN值在传递到标头后保持不变?谢谢。
$body = @{
username = "API"
password = Read-Host "enter password" -MaskInput
grant_type = "password"
};
$response = Invoke-RestMethod "https://....../oauth2/token" -Method Post -Body $body
$token = $response.access_token;
return $token
$headers = @{
Authorization = "Bearer $token"
}
$response = Invoke-RestMethod "https://....../search-total" -Headers $headers
return $response;
1条答案
按热度按时间tmb3ates1#
已通过移动返回语句解决此问题。