Does anybody have an example of how to login to the APIGW from arubacentral?
I can Login to the api, but when i try to authorize, it always tells me that the CSRF-token is missing or incorrect.
My Code: (will be functionized if everything is working, but for testing, this is just quick and dirty)
$URL = $BaseURI+"/oauth2/authorize/central/api/login"
$LoginBody = '{"username":"'+$User_Name+'","password":"'+$Pass_Word+'","client_id":"'+$Client_ID+'"}'
$Request = Invoke-WebRequest -Uri $URL -Method Post -Body $LoginBody -ContentType application/json -SessionVariable Cookies
$Cookies = $Cookies.Cookies.GetCookies($URL)
$URL = $BaseURI+"/oauth2/authorize/central/api"
ForEach ($Cookie in $Cookies)
{
if ($Cookie.Name = "csrftoken")
{
$CSRFToken=$cookie.value
}
if ($Cookie.Name = "session")
{
$Session=$cookie.value
}
}
$Headers = @{"X-CSRF-Token"=$CSRFToken;"session"=$Session}
$AuthenBody = '{"customer_id":"'+$CustomerID+'","client_id":"'+$ClientID+'","CSRF-Token":"'+$CSRFToken+'","session":"'+$Session+'"}'
$Request = Invoke-WebRequest -Uri $URL -Method Post -Body $AuthenBody -ContentType application/json -Headers $Headers