python-keycloak


Namepython-keycloak JSON
Version 4.7.2 PyPI version JSON
download
home_pageNone
Summarypython-keycloak is a Python package providing access to the Keycloak API.
upload_time2024-11-17 10:33:30
maintainerNone
docs_urlNone
authorMarcos Pereira
requires_python<4.0,>=3.9
licenseMIT
keywords keycloak openid oidc
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![CircleCI](https://github.com/marcospereirampj/python-keycloak/actions/workflows/daily.yaml/badge.svg)](https://github.com/marcospereirampj/python-keycloak/)
[![Documentation Status](https://readthedocs.org/projects/python-keycloak/badge/?version=latest)](http://python-keycloak.readthedocs.io/en/latest/?badge=latest)

# Python Keycloak

**python-keycloak** is a Python package providing access to the Keycloak API.

## Installation

Install via PyPI:

`$ pip install python-keycloak`

## Bug reports

Please report bugs and feature requests at
https://github.com/marcospereirampj/python-keycloak/issues

## Documentation

The documentation for python-keycloak is available on [readthedocs](http://python-keycloak.readthedocs.io).

## Keycloak version support

The library strives to always support Keycloak's latest version. Additionally to that, we also support 5 latest major versions of Keycloak,
in order to give our user base more time for smoother upgrades.

Current list of supported Keycloak versions:

- 26.X
- 25.X
- 24.X
- 23.X
- 22.X

## Python version support

We only support Python versions that have active or security support by the Python Software Foundation. You can find the list of active Python versions [here](https://endoflife.date/python).

## Example of Using Keycloak OpenID

```python
from keycloak import KeycloakOpenID

# Configure client
keycloak_openid = KeycloakOpenID(server_url="http://localhost:8080/auth/",
                                 client_id="example_client",
                                 realm_name="example_realm",
                                 client_secret_key="secret")

# Get WellKnown
config_well_known = keycloak_openid.well_known()

# Get Code With Oauth Authorization Request
auth_url = keycloak_openid.auth_url(
    redirect_uri="your_call_back_url",
    scope="email",
    state="your_state_info")

# Get Access Token With Code
access_token = keycloak_openid.token(
    grant_type='authorization_code',
    code='the_code_you_get_from_auth_url_callback',
    redirect_uri="your_call_back_url")


# Get Token
token = keycloak_openid.token("user", "password")
token = keycloak_openid.token("user", "password", totp="012345")

# Get token using Token Exchange
token = keycloak_openid.exchange_token(token['access_token'], "my_client", "other_client", "some_user")

# Get Userinfo
userinfo = keycloak_openid.userinfo(token['access_token'])

# Refresh token
token = keycloak_openid.refresh_token(token['refresh_token'])

# Logout
keycloak_openid.logout(token['refresh_token'])
```

## Example of Using Keycloak Admin API

```python
from keycloak import KeycloakAdmin
from keycloak import KeycloakOpenIDConnection

keycloak_connection = KeycloakOpenIDConnection(
                        server_url="http://localhost:8080/",
                        username='example-admin',
                        password='secret',
                        realm_name="master",
                        user_realm_name="only_if_other_realm_than_master",
                        client_id="my_client",
                        client_secret_key="client-secret",
                        verify=True)

keycloak_admin = KeycloakAdmin(connection=keycloak_connection)

# Add user
new_user = keycloak_admin.create_user({"email": "example@example.com",
                                       "username": "example@example.com",
                                       "enabled": True,
                                       "firstName": "Example",
                                       "lastName": "Example"})

# Add user and raise exception if username already exists
# exist_ok currently defaults to True for backwards compatibility reasons
new_user = keycloak_admin.create_user({"email": "example@example.com",
                                       "username": "example@example.com",
                                       "enabled": True,
                                       "firstName": "Example",
                                       "lastName": "Example"},
                                      exist_ok=False)

# Add user and set password
new_user = keycloak_admin.create_user({"email": "example@example.com",
                                       "username": "example@example.com",
                                       "enabled": True,
                                       "firstName": "Example",
                                       "lastName": "Example",
                    "credentials": [{"value": "secret","type": "password",}]})
```

For more details, see the documentation available on [readthedocs](http://python-keycloak.readthedocs.io).


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "python-keycloak",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "keycloak, openid, oidc",
    "author": "Marcos Pereira",
    "author_email": "marcospereira.mpj@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8c/8c/b5c99ebfab988745ea1480ba99bf4f1c9fd159f7beff3d346b272f43f460/python_keycloak-4.7.2.tar.gz",
    "platform": null,
    "description": "[![CircleCI](https://github.com/marcospereirampj/python-keycloak/actions/workflows/daily.yaml/badge.svg)](https://github.com/marcospereirampj/python-keycloak/)\n[![Documentation Status](https://readthedocs.org/projects/python-keycloak/badge/?version=latest)](http://python-keycloak.readthedocs.io/en/latest/?badge=latest)\n\n# Python Keycloak\n\n**python-keycloak** is a Python package providing access to the Keycloak API.\n\n## Installation\n\nInstall via PyPI:\n\n`$ pip install python-keycloak`\n\n## Bug reports\n\nPlease report bugs and feature requests at\nhttps://github.com/marcospereirampj/python-keycloak/issues\n\n## Documentation\n\nThe documentation for python-keycloak is available on [readthedocs](http://python-keycloak.readthedocs.io).\n\n## Keycloak version support\n\nThe library strives to always support Keycloak's latest version. Additionally to that, we also support 5 latest major versions of Keycloak,\nin order to give our user base more time for smoother upgrades.\n\nCurrent list of supported Keycloak versions:\n\n- 26.X\n- 25.X\n- 24.X\n- 23.X\n- 22.X\n\n## Python version support\n\nWe only support Python versions that have active or security support by the Python Software Foundation. You can find the list of active Python versions [here](https://endoflife.date/python).\n\n## Example of Using Keycloak OpenID\n\n```python\nfrom keycloak import KeycloakOpenID\n\n# Configure client\nkeycloak_openid = KeycloakOpenID(server_url=\"http://localhost:8080/auth/\",\n                                 client_id=\"example_client\",\n                                 realm_name=\"example_realm\",\n                                 client_secret_key=\"secret\")\n\n# Get WellKnown\nconfig_well_known = keycloak_openid.well_known()\n\n# Get Code With Oauth Authorization Request\nauth_url = keycloak_openid.auth_url(\n    redirect_uri=\"your_call_back_url\",\n    scope=\"email\",\n    state=\"your_state_info\")\n\n# Get Access Token With Code\naccess_token = keycloak_openid.token(\n    grant_type='authorization_code',\n    code='the_code_you_get_from_auth_url_callback',\n    redirect_uri=\"your_call_back_url\")\n\n\n# Get Token\ntoken = keycloak_openid.token(\"user\", \"password\")\ntoken = keycloak_openid.token(\"user\", \"password\", totp=\"012345\")\n\n# Get token using Token Exchange\ntoken = keycloak_openid.exchange_token(token['access_token'], \"my_client\", \"other_client\", \"some_user\")\n\n# Get Userinfo\nuserinfo = keycloak_openid.userinfo(token['access_token'])\n\n# Refresh token\ntoken = keycloak_openid.refresh_token(token['refresh_token'])\n\n# Logout\nkeycloak_openid.logout(token['refresh_token'])\n```\n\n## Example of Using Keycloak Admin API\n\n```python\nfrom keycloak import KeycloakAdmin\nfrom keycloak import KeycloakOpenIDConnection\n\nkeycloak_connection = KeycloakOpenIDConnection(\n                        server_url=\"http://localhost:8080/\",\n                        username='example-admin',\n                        password='secret',\n                        realm_name=\"master\",\n                        user_realm_name=\"only_if_other_realm_than_master\",\n                        client_id=\"my_client\",\n                        client_secret_key=\"client-secret\",\n                        verify=True)\n\nkeycloak_admin = KeycloakAdmin(connection=keycloak_connection)\n\n# Add user\nnew_user = keycloak_admin.create_user({\"email\": \"example@example.com\",\n                                       \"username\": \"example@example.com\",\n                                       \"enabled\": True,\n                                       \"firstName\": \"Example\",\n                                       \"lastName\": \"Example\"})\n\n# Add user and raise exception if username already exists\n# exist_ok currently defaults to True for backwards compatibility reasons\nnew_user = keycloak_admin.create_user({\"email\": \"example@example.com\",\n                                       \"username\": \"example@example.com\",\n                                       \"enabled\": True,\n                                       \"firstName\": \"Example\",\n                                       \"lastName\": \"Example\"},\n                                      exist_ok=False)\n\n# Add user and set password\nnew_user = keycloak_admin.create_user({\"email\": \"example@example.com\",\n                                       \"username\": \"example@example.com\",\n                                       \"enabled\": True,\n                                       \"firstName\": \"Example\",\n                                       \"lastName\": \"Example\",\n                    \"credentials\": [{\"value\": \"secret\",\"type\": \"password\",}]})\n```\n\nFor more details, see the documentation available on [readthedocs](http://python-keycloak.readthedocs.io).\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "python-keycloak is a Python package providing access to the Keycloak API.",
    "version": "4.7.2",
    "project_urls": {
        "Changelog": "https://raw.githubusercontent.com/marcospereirampj/python-keycloak/master/CHANGELOG.md",
        "Documentation": "https://python-keycloak.readthedocs.io/en/latest/",
        "Issue tracker": "https://github.com/marcospereirampj/python-keycloak/issues"
    },
    "split_keywords": [
        "keycloak",
        " openid",
        " oidc"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "158c42d3e67e2093ba936fe6a240f6b278afd951ed4fb1c80361a7b897edef48",
                "md5": "143e7bf2c9dd8fadf469fb1338170f35",
                "sha256": "c2751a1ddda7362b6922b0093b553343dcae0f6e39e47be489116ae66d8a9bbb"
            },
            "downloads": -1,
            "filename": "python_keycloak-4.7.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "143e7bf2c9dd8fadf469fb1338170f35",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 77828,
            "upload_time": "2024-11-17T10:33:28",
            "upload_time_iso_8601": "2024-11-17T10:33:28.824494Z",
            "url": "https://files.pythonhosted.org/packages/15/8c/42d3e67e2093ba936fe6a240f6b278afd951ed4fb1c80361a7b897edef48/python_keycloak-4.7.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8c8cb5c99ebfab988745ea1480ba99bf4f1c9fd159f7beff3d346b272f43f460",
                "md5": "962b5f533f8ac6170c0b873fe1ad6cb2",
                "sha256": "9a7fbef6df7b6ad1978ab65d340cc5048e547df1e11771ace661a198932cc4e4"
            },
            "downloads": -1,
            "filename": "python_keycloak-4.7.2.tar.gz",
            "has_sig": false,
            "md5_digest": "962b5f533f8ac6170c0b873fe1ad6cb2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 64005,
            "upload_time": "2024-11-17T10:33:30",
            "upload_time_iso_8601": "2024-11-17T10:33:30.655134Z",
            "url": "https://files.pythonhosted.org/packages/8c/8c/b5c99ebfab988745ea1480ba99bf4f1c9fd159f7beff3d346b272f43f460/python_keycloak-4.7.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-17 10:33:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "marcospereirampj",
    "github_project": "python-keycloak",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "python-keycloak"
}
        
Elapsed time: 1.17476s