Skip to content

Instantly share code, notes, and snippets.

@jcefoli
Created August 2, 2020 05:04
Show Gist options
  • Save jcefoli/4f24620acc0521f895649c933ee6685b to your computer and use it in GitHub Desktop.
Save jcefoli/4f24620acc0521f895649c933ee6685b to your computer and use it in GitHub Desktop.
Authenticate with token to Download File from Raw Githubusercontent
$headers = @{'Accept' = 'application/json'}
$tokenString = "REPLACE-GITHUB-TOKEN-HERE" + ":x-oauth-basic"
$base64Auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(($tokenString)))
$headers.Add('Authorization',"Basic $base64Auth")
$content = Invoke-RestMethod -Uri "https://raw.githubusercontent.com/ORG/Repo/master/something.ps1" -Headers $headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment