Created
September 23, 2016 16:46
-
-
Save megamorf/29c088028730b964168943e6e4484b72 to your computer and use it in GitHub Desktop.
Webrequest - Authorization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$headers = @{} | |
$headers.Add('Authorization', "Bearer $accesstoken") | |
Invoke-RestMethod -Headers $headers -Uri https://graph.microsoft.com/v1.0/me -Method Get |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Step 1. Create a username:password pair | |
$plaintextCredentials = "$($username):$($password)" | |
# Step 2. Encode the pair to Base64 string | |
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($plaintextCredentials)) | |
# Step 3. Form the header and add the Authorization attribute to it | |
$headers = @{} | |
$headers.Add('Authorization',"Basic $encodedCredentials") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment