I am looking for some help with how to use the Egnyte API to make a call using PowerShells invoke-restmethod to list files/folders - https://developers.egnyte.com/docs/read/File_System_Management_API_Documentation#List-File-or-Folder
From their documentation I must first get a oauth2 token which I am unsure how to do so and then authenticate and make the call.
I've come up with the following below however I'm not sure how to proceed...
#credentials
$username = "username"
$password = "password"
$apikey = "api-key"
$token = "token"
#auth to Egnyte
-Username $username -Password $password -AccessKey $apikey -token $token
Invoke-RestMethod -Uri https://EgnyteDomain.egnyte.com/pubapi/v1/fs/