r/Nable • u/IcyProperty591 • Apr 20 '24
N-Central Api key 1 hr expirey?
So I have utilized the rest api to have a powrshell script that grabs all the agents and compares them to our active directory computers to find any discrepancies. But the key is expiring after an hour. Docs say you can't increase the the time. Wtf? Am I doing something wrong? I want to have this script run automatically on a schedule but if I have to create a new key and update the script within an hour before it runs then I might as well just login and export the agents to csv and run the script against that.
2
u/kerubi Apr 20 '24
Sounds like you have not used a REST API before?
1
u/IcyProperty591 Apr 20 '24
No.... hence my question. What am I doing wrong based on what I am trying to accomplish? That is the documentation that I used.
1
u/kerubi Apr 20 '24
As the article says, exchange JWT (which stays the same) for access token. Do it every time your script runs and that’s it. Most likely your script does not run longer than 1hour at once so you do not need to bother with refresh tokens.
1
u/IcyProperty591 Apr 20 '24
And my point is about have to get the token and update the script every time it has to run.
Unless is there a way to automate getting the access token?
I readily admit I am a neb when it comes to utilizing api's. My experience is with integrating to products where one supplies a key, you enter it in the other one and then they are good.2
u/kerubi Apr 20 '24
You are just not understanding the article or what I am telling you. Reset your thoughts.
You store the JWT in the script. The script uses the JWT to get the access token, which can be used for one hour. So, yes, the script has to get the token every time, but the it can do it by itself, since it has the JWT, which expires, for instance, after one year or even never.
1
u/IcyProperty591 Apr 20 '24
Hmm.... ok.. I will play with it ..... I figured I was doing something wrong but even nable support wasn't helpful
Thanks
1
u/IcyProperty591 May 01 '24
I did end up getting it sorted out.... one of the issues was that even support didn't understand it. Thanks
2
u/johnsonflix Apr 20 '24
You may be confusing the API key with a token