Posted by mRiston
Henagon

Token Issue Getting List of TV Devices

Hey all, I'm trying to use PowerShell to query my TV account to retrieve a list of all of our computers. I'm working on trying to use the last_seen return value as part of an internal cleanup project.

In reading through the API and using a few of the pre-existing scripts on the internet, but am receiving the following error when trying to pull GET against api/v1/devices. 

{"error":"invalid_token","error_description":"Access token is of wrong type. You need a UserToken to call this function.","error_code":2}

Example code:

$TeamViewer_APIKey = ''

$bearer = "Bearer",$TeamViewer_APIKey
$header = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$header.Add("authorization", $bearer)

$request = Invoke-RestMethod -Uri "https://webapi.teamviewer.com/api/v1/devices" -Method Get -Headers $header

 

1 Reply
1 Accepted Solution

Accepted Solutions
Posted by mRiston
Henagon
Solution

Re: Token Issue Getting List of TV Devices

Turns out the usage of a company API key is different than one for an individual account. I deleted the company API key I had before and regenerated one for just my individual admin account and am good to go.
1 Reply
Posted by mRiston
Henagon
Solution

Re: Token Issue Getting List of TV Devices

Turns out the usage of a company API key is different than one for an individual account. I deleted the company API key I had before and regenerated one for just my individual admin account and am good to go.