Skip to content

Don't invalidate access token after each request #50

@igneus

Description

@igneus

Is your feature request related to a problem? Please describe.

When I authenticate using access token and user ID (rather than username and password), first request passes, but the second and any further request always results in error 401 Unauthorized and my precious access token disappears (from the access token administration in RocketChat UI).

import os

chat = RocketChatAPI({
    # authenticate using a personal access token
    'user_id': os.getenv('ROCKETCHAT_USERID'),
    'token': os.getenv('ROCKETCHAT_TOKEN'),

    'domain': 'https://my.domain.eu',
})

# make first request to find a room
all_rooms = chat.get_public_rooms()
room_name = 'name'
room_id = [x for x in all_rooms if x['name'] == room_name][0]

# attempt second request, which fails with 401 Unauthorized
chat.send_message('Message text', room_id)

It turned out that it's because after each request a call to RocketChatBase.logoff() is made, which calls the deadly /api/v1/logout endpoint, which does exactly what the documentation says:

Invalidate your REST API authentication token.

Describe the solution you'd like

When authenticating using access token, the library should never call RocketChatBase.logoff() on it's own.

Describe alternatives you've considered

I don't see any reasonable alternatives.

Additional context

No additional context available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions