New to Powershell here so any advice is appreciated! I'm Posting to this website's API (I code-named it authenticate.com in the below code) to receive in the response an auth token as a cookie. The next objective is to take the cookie and use it to validate to a different API. How can I capture the auth-token returned by the first API and save it into a variable?
My code:
$Url = 'https://authenticate.com/apikeylogin'
$auth = @{
keyPublic= '********************'
keySecret= '********************'
}
$json = $auth | ConvertTo-Json
$response = Invoke-WebRequest $Url -Method Post -Body $json -ContentType 'application/json'
$response | Get-Member
$response.RawContent
The response in raw-text:
HTTP/1.1 200 OK
auth-token: ******************
[Below this is are a dozen more lines of raw data]
To restate the question, how do I get the above value of 'auth-token' and store it into a variable?