RidersDiscountCom/HypChat

Throws 401 for every command

bluszcz opened this issue · 5 comments

Going trough the example (and using both types of tokens - notifications and admin ones) I am getting following error for every operation:

HttpUnauthorized: {
  "error": {
    "code": 401,
    "message": "Invalid OAuth session",
    "type": "Unauthorized"
  }
}

Same tokens are working in other applications.

Going to need more details. If you set __HYPCHAT_DEBUG_REQUESTS__ in your environment, do the URLs look wrong in any way?

I had this happen last week. The problem sorted it's self out after a few minutes. I'm thinking it was probably something with OAuth on the HipChat side, but until it rears it's ugly head again it's hard to track down.

I can say that I had two different servers connecting to HipChat using the same key. The first time I tried connecting the the second server (pushing from a local dev system to a staging server) is when it happened. Maybe that has something to do with it.

I'll keep this open for now and we can revisit it when someone is able to reliably reproduce the issue with debug information.

Hi, I have the same problem. Trying with several API tokens (admin and notification) I get the following traceback:

REQUEST GET https://api.hipchat.com/v2/room
Traceback (most recent call last):
  File "hipchat.py", line 6, in <module>
    rooms = hc.rooms()
  File "/usr/local/lib/python2.7/dist-packages/hypchat/restobject.py", line 85, in __call__
    rv = self._obj_from_text(self._requests.get(self.url, params=params).text, self._requests)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 468, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hypchat/__init__.py", line 55, in request
    resp = super(_requests, self).request(method, url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hypchat/requests.py", line 341, in request
    raise _http_errors[rv.status_code](rv.text, response=rv)
hypchat.requests.HttpUnauthorized: {
  "error": {
    "code": 401,
    "message": "Invalid OAuth session",
    "type": "Unauthorized"
  }
}

In hipchat.py I instantiate a HypChat object with my token and call its rooms method.
Edit: testing with curl showed that
curl https://api.hipchat.com/v1/rooms/list?auth_token=TOKEN
works, but
curl https://api.hipchat.com/v2/room?auth_token=TOKEN
gives the same http error.

You are using the token from: hipchat.com/account/api
and not: hipchat.com/admin/api correct?

Sounds like you're using a v1 token.

You're right, I was using the wrong API token. It works ok with the v2 token now. Thanks!