I have an unattended/automated task that uses the OTCS REST API to perform searches and add documents.
I would like to convert it to use the OAuth2 Client Credentials grant flow, so I can use a client secret rather than a username/password.
I have set up a new OAuth client in OTDS with default values, and have the client secret. I can use this info via powershell to gain an OAuth access_token using the /otdsws/oauth2/token
API:
$headers = @{
Authorization = "Bearer $accessToken"
}
$params = @{
requested_token_type="urn:ietf:params:oauth:token-type:access_token"
grant_type="client_credentials"
client_secret="(client secret here)"
client_id="(client name here)"
}
Invoke-RestMethod "https://(otds url)/otdsws/oauth2/token" -Method 'POST' -Headers $headers -Body $params | Select -ExpandProperty access_token
This call is successful and I get the access token OK, however I need to convert this token into something I can use in the call to OTCS, as the OAuth access token is not usable as an OTDS/OTCS ticket:
$hdrs = @{
"otcsticket"="$otcsticket"
}
Invoke-RestMethod "https://(otcs url)/otcs/cs.exe/api/v1/nodes/2000" -Headers $hdrs
Any input appreciated, thanks,