February 2019
Intermediate to advanced
626 pages
15h 51m
English
Basic authentication with a username and password is the simplest method available:
$params = @{ Uri = 'https://api.github.com/user/emails' Credential = Get-Credential}Invoke-RestMethod @params
In PowerShell Core, the Authentication parameter should be added:
$params = @{ Uri = 'https://api.github.com/user/emails' Credential = Get-Credential Authentication = 'Basic'}Invoke-RestMethod @params
If the account is configured to use two-factor authentication, this request may fail with the following error message:
PS> Invoke-RestMethod @paramsInvoke-RestMethod : {"message":"Must specify two-factor authentication OTP code.","documentation_url":"https://developer.github.com/v3/auth#working-with-two-factor-authentication"} ...Read now
Unlock full access