February 2019
Intermediate to advanced
626 pages
15h 51m
English
We can call methods that require authentication by adding a token to the HTTP header.
The format of the authorization header field is shown here:
Authorization: token OAUTH-TOKEN
OAUTH-TOKEN is replaced and the authorization head is constructed as shown here:
$headers = @{ Authorization = 'token {0}' -f $token}
The token can be used in subsequent requests for the extent of its lifetime:
$headers = @{ Authorization = 'token {0}' -f $token}Invoke-RestMethod 'https://api.github.com/user/emails' -Headers $headers
Read now
Unlock full access