windows
Basic认证
$pwd = ConvertTo-SecureString "MyPassword" -AsPlainText -Force
$cred = New-Object Management.Automation.PSCredential ('PsUser', $pwd)
Invoke-RestMethod 'http://httpbin.org/basic-auth/PsUser/MyPassword' -cred $cred
Linux
Basic认证
curl --basic -u user:password http://www.example.com/posts/1
Digest认证
curl --digest -u user:password http://www.example.com/posts/1
OAuth2认证
curl -u clientId:clientSecret -X POST -d "username=test&password=test&grant_type=password&scope=read" http://www.example.com/oauth/token
curl -H "Authorization: Bearer [bearer]" http://www.example.com/posts/1