To retrieve new token once expired from automated java program

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.



1 answer

Hi Reji,

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" "" \
    --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!

Suggest an answer

Log in or Join to answer
Community showcase
Maarten Cautreels
Published Oct 07, 2017 in Hipchat

Bringing Structure to your HipChat Instance

...have mention name FirstnameLastname. Fe.: @MaartenCautreels This certainly helps to know who is being mentioned in a conversation. Imagine your colleague sends the following message...

464 views 1 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot