Skip to content

Auto refresh token #6

@kbumsik

Description

@kbumsik

Hi,

Thank you for making a proper org feature in Keycloak!

We have been using keycloak-org for weeks with this Python client.

I noticed that python-keycloak package automatically refresh token when the token is expired, but this package does not.

Because of this, every time I make a request I have to refresh token (when expired) and create phasetwo.Configuration and phasetwo.ApiClient

keycloak_admin = KeycloakAdmin(server_url="https://my-keycloak-host/auth/",
                               username='admin',
                               password='password',
                               realm_name=realm,
                               client_id='admin-cli',
                               verify=True)

# Before making a request
if (keycloak_admin.connection.expires_at is None) or (datetime.now() >= keycloak_admin.connection.expires_at):
            keycloak_admin.connection.refresh_token()

configuration = phasetwo.Configuration(
    host = "https://app.phasetwo.io/auth/realms"
    access_token = keycloak_admin.token()
)

client = phasetwo.ApiClient(configuration)

Devs won't notice this until they come across this issue.

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