How to integrate hipchat in a website?

518 Views Asked by At

I am trying to integrate hip chat i my website.
Hip chat doc

I go through above doc.But i am able to understand how to start. They are saying to create add on and many thing. Using api i am able to post and get data but of only one user. I want to integrate Hip chat like a chat server in my website but i don't
How to start and how to implement that. If any one have example or demo plz help me.
Below is the code what i tried:

// getting all room information

// Rooms
"https://api.hipchat.com/v2/room?auth_token=XXXXXX"

//message to room
https://api.hipchat.com/v2/room/2068981/notification?auth_token=XXXXXX

//Message history
https://api.hipchat.com/v2/room/2068981/history?auth_token=XXXXXX&max-results=1000&reverse=true

this code are working fine .But it is only working for one user i want it to work of all user . And I am also not able to generate access token for every user automatically. I tried for access token :

curl -d '{"username":"[email protected]","grant_type":"password","password":"XXXX"}' -H 'Content-Type: application/json' https://domain.hipchat.com/v2/oauth/token
{
  "error": {
    "code": 401,
    "message": "Authenticated requests only. See https://www.hipchat.com/docs/apiv2/auth for more information.",
    "type": "Unauthorized"
1

There are 1 best solutions below

2
On BEST ANSWER

I think you will not be able to post on behalf of all users using just one token. It's a security issue. Instead you may need to do the following

  1. Require users to login in your website
  2. Create an page for them to grant access to HipChat
  3. Bind the access token returned from HipChat to their profile in your website
  4. Use corresponding token to post on behalf of users when they logged in