Skip to main content

I’m attempting to connect to the Netskope API via a PowerShell script. I’ve created an access token with the appropriate endpoint configured. The script is receiving a 401 response which indicates that I’m not authorized yet. I’m not sure how to present the access token in the header. Is there any documentation or examples on how to authorize to the API endpoint I’m trying to connect to?

 

Here’s a snippet of my PowerShell script:

# Variables
$netskopeAccessToken = "<insert_access_token_here"
$type = "File, Folder"
$filter = "(app eq 'OneDrive') and (exposure eq 'External')"
$netskopeUri = "https://<domain>.goskope.com/api/v2/ui/casbapi/inventory/resources"

# API Header
$headers = @{
'Authorization' = 'api_key' + $netskopeAccessToken
'Accept' = 'application/json'
}

# API Body
$body = @{
type = $type
filter = $filter

}

$response = Invoke-RestMethod -Uri $netskopeUri -Method Get -Body $body -Headers $headers


 

Be the first to reply!

Reply