Thanks for the link to the PDF and the sample Python code.
According to the document the API expects a JSON request body too which does not make sense if you look at the Curl and Python examples. However, I’ve created a couple of examples below of which one will hopefully work for you.
As I understand (page 3 of the PDF), you’ll need to go into appliance portal and generate an access code, and replace the place holders in my examples before going ahead. Obviously the access code provided in the Curl and Python examples won’t work for the appliance you’ve access to.
I hope that helps. I can offer you to have a Zoom screen sharing session for free if you’re still stuck with getting this to work. Unfortunately, I don’t have access to this kind of appliance. Please let us know.
Example 1a - JSON request body and access code with Base64 encoding:
$uri = 'https://192.168.110.90/api/common/1.0/oauth/token'
$algorithm = "{`"alg`":`"none`"}\n"
$accessCode = 'PasteAccessCodeFromAppliancePortalHere'
$algorithmBase64 = [Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($algorithm))
$accessCodeBase64 = [Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($accessCode))
$params = @{
ContentType = 'application/x-www-form-urlencoded'
Headers = @{'accept'='application/json'}
Body = @{
'grant_type' = 'access_code'
'assertion' = '{0}.{1}.' -f $algorithmBase64, $accessCodeBase64
'state' = 'state_string'
} | ConvertTo-Json
Method = 'Post'
URI = $uri
}
Invoke-RestMethod @params
Example 1b - JSON request body and access code w/o Base64 encoding:
$uri = 'https://192.168.110.90/api/common/1.0/oauth/token'
$algorithm = "{`"alg`":`"none`"}\n"
$accessCode = 'PasteAccessCodeFromAppliancePortalHere'
$algorithmBase64 = [Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($algorithm))
$params = @{
ContentType = 'application/x-www-form-urlencoded'
Headers = @{'accept'='application/json'}
Body = @{
'grant_type' = 'access_code'
'assertion' = '{0}.{1}.' -f $algorithmBase64, $accessCode
'state' = 'state_string'
} | ConvertTo-Json
Method = 'Post'
URI = $uri
}
Invoke-RestMethod @params
Example 2a - URI request body format and access code with Base64 encoding:
$uri = 'https://192.168.110.90/api/common/1.0/oauth/token'
$algorithm = "{`"alg`":`"none`"}\n"
$accessCode = 'PasteAccessCodeFromAppliancePortalHere'
$algorithmBase64 = [Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($algorithm))
$accessCodeBase64 = [Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($accessCode))
$params = @{
ContentType = 'application/x-www-form-urlencoded'
Headers = @{'accept'='application/json'}
Body = 'grant_type=access_code&assertion={0}.{1}.&state=state_string' -f $algorithmBase64,
$accessCodeBase64
Method = 'Post'
URI = $uri
}
Invoke-RestMethod @params
Example 2b - URI request body format and access code w/o Base64 encoding:
$uri = 'https://192.168.110.90/api/common/1.0/oauth/token'
$algorithm = "{`"alg`":`"none`"}\n"
$accessCode = 'PasteAccessCodeFromAppliancePortalHere'
$algorithmBase64 = [Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($algorithm))
$params = @{
ContentType = 'application/x-www-form-urlencoded'
Headers = @{'accept'='application/json'}
Body = 'grant_type=access_code&assertion={0}.{1}.&state=state_string' -f $algorithmBase64,
$accessCode
Method = 'Post'
URI = $uri
}
Invoke-RestMethod @params