I'm having trouble using pyCentral and managing/refreshing tokens to my central on prem instance. I am not using OAUTH, but just token access. I assumed this code would work as expected, storing the most recent token and refresh token in the default token_store (/temp/tok_None_*****). My central_info looks like:
central_info = {
"base_url": "https://apigw-cop.*********",
"client_secret": "3jorSOIozX**************",
"client_id": "KxOg******************************",
}
def connect_to_central():
ssl_verify = True
central = ArubaCentralBase(central_info=central_info,
ssl_verify=ssl_verify)
central.refreshToken(central.getToken())
central.storeToken()
return central
However, refreshToken seems to return the new token but not actually update the connection object? So I have to do something like:
def connect_to_central():
ssl_verify = True
central = ArubaCentralBase(central_info=central_info,
ssl_verify=ssl_verify)
newToken = central.refreshToken(central.getToken())
newToken['grant_type'] = "refresh_token"
central.storeToken(newToken)
central.loadToken()
return central
Which also doesn't seem to work correctly. At this point I am starting to believe that I am misunderstanding something fundamental and should stop poking and ask for some advice. Ultimately, I am trying to write a script that periodically pulls data from Central On Prem, and "handles" token management.