Skip to content

Instantly share code, notes, and snippets.

@AlexanderHolmeset
Created December 15, 2022 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexanderHolmeset/c9c34b9e9d737da41168d74d4e11a59d to your computer and use it in GitHub Desktop.
Save AlexanderHolmeset/c9c34b9e9d737da41168d74d4e11a59d to your computer and use it in GitHub Desktop.
#Authentication
$consumerToken = "Enter your consumer token here"
$employeeToken = "enter your employee token here"
#Expiration date of the authorization toke you generate is set to 1 day from now.
$expirationDate = get-date ((get-date).Adddays(+1)) -format "yyyy-MM-dd"
$uri = "https://tripletex.no/v2/token/session/:create?consumerToken=$consumerToken&employeeToken=$employeeToken&expirationDate=$expirationDate"
#Get token and create header.
$token = ((Invoke-RestMethod -Method PUT -Uri $uri -ContentType "application/JSON").value).token
$user = '0'
$pass = $token
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$Header = @{"Authorization" = "Basic $encodedCreds"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment