Loads of admin app tokens (PSU 4.2.13)

This happen to me too,
Here is a function I write to delete all the leftovers:

function ClearTokens {

param ([String]$server,[String]$AuthToken)

$TokenID = (Invoke-RestMethod "https://$($server)/api/v1/apptoken" -Method GET -Headers @{Authorization = "Bearer $AuthToken"}).id
$TokenID | % { Invoke-RestMethod "https://$($server)/api/v1/apptoken/$($_)" -Method DELETE -Headers @{Authorization = "Bearer $AuthToken"} }
}

ClearTokens -server "psu.domain.local" -AuthToken $token
1 Like

Great! I haven’t succceeded in upgrading yet, but a token purge seems like a good idea anyway…

I did a little addition so it doesn’t remove my “real” tokens. Pasting below for anybody that stumbles over this:

function ClearTokens {

  param ([String]$server,[String]$AuthToken)

  $TokenID = (Invoke-RestMethod "https://$($server)/api/v1/apptoken" -Method GET -Headers @{Authorization = "Bearer $AuthToken"}) | Where-Object {$_.identity.name -eq "admin"}
  $TokenID | % { Invoke-RestMethod "https://$($server)/api/v1/apptoken/$($_.id)" -Method DELETE -Headers @{Authorization = "Bearer $AuthToken"} }
}

I’d maybe also add a check to see that the token’s ever been used, or if it’s expired (assuming they’re not set to never expire).

Good point. They’re set to expire in one year, so I’ll delete them even if not expired now, but a check on lastUsed -eq $null seems like a good idea!

1 Like

this is a gap in my knowledge related to the MSI install specifically, but there should be at least some level of logging that the server generates locally - are you able to find anything in the log files on the server? i believe relevant logs will automatically go within the /bin/logs folder but again i’m not sure how the MSI install handles that. if you can find anything, you may see what could be causing the error too.

also just to confirm, as this i believe was only inferred earlier: you’re trying to go from 4.2.13 to 4.4.0?