To pull list of all files in a folder of zoho workdrive using REST API

To pull list of all files in a folder of zoho workdrive using REST API

Hello Team,

I am trying to connect Zoho workdrive using REST API with powershell and List the files and folders to get the properties of the files especially the embed code of the video files.

I am able to get the refresh token and access token.
However when I try to run the invoke request for listing files of a folder it says 
Invoke-RestMethod : {"errors":[{"id":"F000","title":"INVALID_SCOPE"}]}

I tried WorkDrive.files.READ and WorkDrive.files.ALL both but its same error all the time.

Here is my script:


$tokenParams = @{
    client_id     = "1000.XXXXXXXXXXXXXXSL"
    client_secret = "bb8XXXXXXXX38e3a0eab"
    redirect_uri  = "https://www.google.com/callback"
    code          = "1000.6eXXXXXXXXXXXXXXXXX8d"
    grant_type    = "authorization_code"
}

$response = Invoke-RestMethod -Uri $tokenUrl -Method Post -Body $tokenParams

# Display the entire response to view all details
$response

$accessToken = $response.access_token
$refreshToken = $response.refresh_token
Write-Host "Access Token: $accessToken"
Write-Host "Refresh Token: $refreshToken"

$folderId = "ahtl1cf04bXXXXXXXX816e93cb9"

$headers = @{
    "Authorization" = $newAccessToken
}

$response = Invoke-RestMethod -Uri $url -Method Get -Headers $headers