Created
December 15, 2022 20:44
-
-
Save AlexanderHolmeset/c9c34b9e9d737da41168d74d4e11a59d to your computer and use it in GitHub Desktop.
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
#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