Original Message:
Sent: Sep 30, 2024 04:03 PM
From: joseph.gullo.pcci
Subject: Assistance in automating token creation and renewal?
That was the clue I needed, I didn't realize the clusters weren't shared and that our account only exists on one, Thank you!
Original Message:
Sent: Sep 30, 2024 03:46 PM
From: Tiffany.Chiapuzio-Wong
Subject: Assistance in automating token creation and renewal?
Hi @joseph.gullo.pcci! Just wanted to verify you're following these instructions for retrieving the Client ID & Secret:
https://developer.arubanetworks.com/hpe-aruba-networking-central/docs/api-gateway-creating-application-token
Also I noticed between the two examples you're using two different API gateways, in the first it's
apigw-uswest4.central.arubanetworks.com
and in the second it's
app1-apigw.central.arubanetworks.com
Which cluster are you using?
------------------------------
Ti Chiapuzio-Wong (they/them)
HPE Aruba Networking
Original Message:
Sent: Sep 27, 2024 11:15 AM
From: joseph.gullo.pcci
Subject: Assistance in automating token creation and renewal?
We are getting started with using the api to do some automation, but we're having issues with the token acquisition process. I have a client ID (personal and system) and can make an access token in the web UI, then copy and paste it into my code and execute functions, but when I go to request the initial token or renew it I get an error "invalid client_ID". I have to guess I have a syntax problem, but I have tried it using REST in PowerShell and using pycentral and I'm seeing the same thing. I am pretty sure my API App is fine because, like I said, I can download and use an access token from the web GUI, but if I try to automate that it fails. Below is some sample code to show what I'm doing, so if anything jumps out that I'm doing wrong I would appreciate any feedback.
PowerShell
$CLIENT_ID="#######################"$BASE_URL="apigw-uswest4.central.arubanetworks.com"$API_URI="https://"+$BASE_URL+"/oauth2/authorize/central/api/login?client_id="+$CLIENT_ID$headers = @{ "accept" = "application/json"}$body = @{ "username" = "#########@###.com" "password" = "#################"} | convertto-jsonInvoke-RestMethod -Method POST -ContentType 'application/json' -Headers $headers -Body $body -uri $API_URIInvoke-RestMethod : {"extra":null,"message":"Invalid client ID"}
Python
>>> from pycentral.base import ArubaCentralBase>>> from pprint import pprint>>> central_info = {... "username": "#######@#####.com",... "password": "#################",... "client_id": "#################",... "client_secret": "#################",... "customer_id": "################",... "base_url": "https://app1-apigw.central.arubanetworks.com"... }>>> ssl_verify = True>>> central = ArubaCentralBase(central_info=central_info, token_store=None, ssl_verify=ssl_verify)2024-09-27 08:01:52 - ARUBA_BASE - ERROR - Unable to load token from storage with error .. [Errno 2] No such file or directory: 'C:\\Working\\Python.ArubaCentral\\temp\\tok_800aaf4c826e446897a88f0d70845122_jtmgv3wP9f0RWeZS9j0uAZH6J2aK76Vf.json'2024-09-27 08:01:52 - ARUBA_BASE - INFO - Attempting to create new token from Aruba Central2024-09-27 08:01:53 - ARUBA_BASE - ERROR - OAUTH2.0 Step1 login API call failed with response {'code': 400, 'msg': '{"extra":null,"message":"Invalid client ID"}\n'}