EgnytePermissions/API Tokens/Revoke-OldToken.ps1
2023-09-14 10:56:07 -06:00

27 lines
694 B
PowerShell

$token1 = Get-content -Path .\bearer.token
$client_secret = 'MAhCqnVAUUq7RvR73wMd5FB9dUP3hhfwGCB7jrXcG8g9gzCQ3a'
$token = 'token=' + $token1 + '&client_secret=' + $client_secret
$BasePath = 'https://mpe.egnyte.com'
$RevokePath = $BasePath + '/pubapi/v1/tokens/revoke'
$eg_header = @{
'Content-Type' = 'application/x-www-form-urlencoded'
'Connection' = 'close'
'Authorization' = 'Bearer ' + $token1
}
# $body = @{
# $
# }
$Revoke_Response = Invoke-WebRequest -Uri $RevokePath -HttpVersion 1.1 -Method Post -body $token -Headers $eg_header
if ($Revoke_Response.StatusCode -eq 200) {
write-output "token revoked successfully, deleting"
remove-item .\bearer.token
}