Skip to main content

OneLogin API Python SDK

Project description

onelogin-python-sdk

Official Python SDK for the OneLogin API. Manage users, roles, groups, apps, and authentication programmatically.

API reference: OneLogin API Documentation. Per-endpoint docs: see docs/ in this repo.

Support

OneLogin by One Identity open-source projects are supported through GitHub. For help, please open an issue: https://github.com/onelogin/onelogin-python-sdk/issues. Requests filed via official One Identity Support are redirected here so all users can benefit.

Requirements

  • Python 3.10+
  • Pydantic 2.11+ (enforced via pyproject.toml)

Installation

pip install onelogin

For development:

pip install -e ".[test,lint]"

Getting Started

import os
import onelogin
from pprint import pprint

configuration = onelogin.Configuration(
    host="https://your-subdomain.onelogin.com",
    username=os.environ["ONELOGIN_CLIENT_ID"],
    password=os.environ["ONELOGIN_CLIENT_SECRET"],
)

with onelogin.ApiClient(configuration) as api_client:
    # Exchange client credentials for an access token.
    token_api = onelogin.OAuth2Api(api_client)
    token = token_api.generate_token({"grant_type": "client_credentials"})
    configuration.access_token = token.access_token

    # Now make authenticated calls.
    users_api = onelogin.UsersV2Api(api_client)
    pprint(users_api.list_users2())

Authentication

OneLogin uses OAuth2 client credentials. Generate a Client ID + Client Secret under Security → API Credentials in the OneLogin admin portal, with one of:

  • Authentication Only — Verify Factor, Generate SAML Assertion, Create Session Login Token, Log User Out
  • Read UsersGET on User, Role, Group resources
  • Manage UsersGET/POST/PUT/DELETE on User, Role, Group (no password management or role assignment)
  • Read All — read-only across all resources
  • Manage All — full access including password management and role assignment

Tests

pip install -e ".[test]"
pytest

Troubleshooting

  • ImportError: cannot import name validate_call from pydantic — Pydantic <2.11 in your environment. Run pip install -U pydantic.
  • ValidationError on response deserialization — likely a server-returned null for a field the SDK still types as required. Open an issue with the endpoint and a redacted response sample; this class of fix is straightforward (see PR #126, #131 for examples).
  • Connection issues — confirm your subdomain in the host URL, that your credentials carry the right scope, and that your network can reach *.onelogin.com.

Release Process (Maintainers)

Releases ship to PyPI automatically when you publish a GitHub Release. The publish workflow runs sed -i against pyproject.toml and onelogin/__init__.py inside the CI runner to set the version from the tag — those edits are not committed back to main, so the source tree may lag the latest PyPI release. Reconcile periodically with a manual version bump PR.

  1. Open the Releases page and click Draft a new release
  2. Create a tag matching the version, e.g. 3.2.9 (no v prefix; matches releases 3.2.4 onward)
  3. Set title to the version and paste the CHANGELOG entry into the description
  4. Publish release.github/workflows/python-publish.yml builds and uploads to PyPI

If a release fails to upload, re-run the failed workflow from the Actions tab; the build is idempotent up to the point of twine upload.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onelogin-4.0.0.tar.gz (125.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

onelogin-4.0.0-py3-none-any.whl (275.2 kB view details)

Uploaded Python 3

File details

Details for the file onelogin-4.0.0.tar.gz.

File metadata

  • Download URL: onelogin-4.0.0.tar.gz
  • Upload date:
  • Size: 125.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for onelogin-4.0.0.tar.gz
Algorithm Hash digest
SHA256 b33954ca0fc503126ebe18d6ea36040d9edbc67c7aff9f8a1a146dc94d555622
MD5 4e8a71aecf4e51a905cdcff9bdf192e6
BLAKE2b-256 9e8916f241b82af5f75561504390939e84e3e10c7c0fa9ad1020d6946b8302c2

See more details on using hashes here.

File details

Details for the file onelogin-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: onelogin-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 275.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for onelogin-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c30d3b4fdc438944dce183ab2185199c50edb524a172da6aba5eaaf0f92b3e81
MD5 0e2838d92f0f7f6f15e57e2727faa693
BLAKE2b-256 7d315cced11a38ce1c2a913f3397c208cb6328f46a374dc6761f3b456def3604

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page