We are developing a standalone java batch process program in my company which read employee info from csv file to Create User account in Hipchat by calling Rest api. We need token to access Hipchat Rest api. So far I used personal access token which is hard coded in java file. As we are going to schedule this batch process, the new token need to be retrieved or refreshed when the given token expires.
1) please let me know personal access token validity
2) As per my understanding token expiration time is one year
2) How to retrieve a token from my automated program once token is expired
Please suggest me how I can achieve this.
You are correct that personal tokens for the V2 HipChat API are valid for a period of 1 year before expiring. There is no way to refresh a personal token through the API.
Updating once every year manually may be sufficient for your purposes, if not the I would suggest instead creating an integration as you need access to the GROUP_ADMIN (we have some instructions available on the hipchat documentation).
Once you have an installed an integration generating a new access token is only a matter of calling the generate token method on HipChat's rest API. This should be called with your required scopes, a grant type of client credentials, and using basic auth with your oauth session / secret. These tokens last for an hour, so you would probably want to grab a new token each time you start an import (depending on how long these take / the time between).
curl -X "POST" "https://www.hipchat.com/v2/oauth/token" \ -u OAUTH_ID:OAUTH_SECRET \ --data-urlencode "scope =GROUP_ADMIN" \ --data-urlencode "grant_type =client_credentials "
One additional point if you decide to go down the integration route - once installed you wouldn't actually need to keep the integration running. You only need to save a copy of the OAuth ID + secret somewhere that you can use for your batched task. Please make sure you keep this information somewhere safe, as it would have admin access to your HC server.
Hope this information helps!
All good things come to an end - thanks to all our customers and partners who have been along the Hipchat and Stride journey with us. As of Feb 15th 2019, Hipchat Cloud and Stride have reached ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events