{"id":21640,"library":"onelogin","title":"OneLogin Python SDK","description":"Official Python SDK for the OneLogin API (v1 and v2). Supports OAuth2 authentication, user and role management, event and factor APIs, and SAML assertion handling. Current version 3.2.5, requires Python >=3.10. Active development with quarterly releases.","status":"active","version":"3.2.5","language":"python","source_language":"en","source_url":"https://github.com/onelogin/onelogin-python-sdk","tags":["onelogin","sso","saml","api-sdk","oauth2","identity-management"],"install":[{"cmd":"pip install onelogin","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"HTTP client used by all API calls","package":"requests","optional":false},{"reason":"Data models for API responses (v2)","package":"pydantic","optional":false},{"reason":"SAML assertion signing/verification","package":"cryptography","optional":true}],"imports":[{"note":"Client is in the api submodule, not top-level","wrong":"from onelogin import OneLoginClient","symbol":"OneLoginClient","correct":"from onelogin.api.client import OneLoginClient"},{"note":"ApiClient is inside a package named api_client","wrong":"from onelogin.api_client import ApiClient","symbol":"ApiClient","correct":"from onelogin.api.api_client import ApiClient"},{"note":"AuthClient lives under onelogin.api","wrong":"from onelogin.auth_client import AuthClient","symbol":"AuthClient","correct":"from onelogin.api.auth_client import AuthClient"}],"quickstart":{"code":"import os\nfrom onelogin.api.client import OneLoginClient\n\nclient = OneLoginClient(\n    client_id=os.environ.get('ONELOGIN_CLIENT_ID', ''),\n    client_secret=os.environ.get('ONELOGIN_CLIENT_SECRET', ''),\n    region='us'\n)\n# Fetch users\nusers = client.get_users()\nprint(f\"Fetched {len(users)} users\")","lang":"python","description":"Initialize the OneLogin client and fetch a list of users."},"warnings":[{"fix":"Use keyword arguments: OneLoginClient(client_id=..., client_secret=..., region='us')","message":"In v3.x, the constructor changed from (region, client_id, client_secret) to (client_id, client_secret, region). Passing positional arguments in the old order will swap credentials.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use create_user2() and handle the User model returned.","message":"Methods like create_user() are deprecated in favor of create_user2(). The v2 endpoints return different response structures.","severity":"deprecated","affected_versions":">=2.0.0 <4.0.0"},{"fix":"Access attributes via dot notation (e.g., user.email) rather than user['email'].","message":"The library uses Pydantic v2 for data models. Direct dictionary access on responses may fail if you expected simple dicts.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Wrap API calls with token expiry check or call authenticate() before each batch.","message":"OAuth2 access tokens expire after 3600 seconds. The client does not auto-refresh – you must call client.refresh_token() or re-authenticate.","severity":"gotcha","affected_versions":"all"},{"fix":"Migrate to the new client and use v2 endpoints where possible.","message":"In v2.0.0, the SDK was rewritten to support both API /1 and /2. Old v1 SDK scripts (pre-2.0) are not compatible.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use the correct import: from onelogin.api.client import OneLoginClient","cause":"Importing from the wrong module or using an outdated import pattern.","error":"AttributeError: 'OneLoginClient' object has no attribute 'get_users'"},{"fix":"Re-authenticate: client.authenticate() or refresh token with client.refresh_token()","cause":"OAuth2 token expired or invalid client credentials.","error":"OneLogin.api.OneLoginException: Error: 401 - Unauthorized"},{"fix":"Use keyword arguments: OneLoginClient(client_id=..., client_secret=..., region='us')","cause":"Passing positional arguments in wrong order (v3 changed constructor signature).","error":"TypeError: __init__() got multiple values for argument 'client_id'"},{"fix":"Upgrade to onelogin>=3.2.1 which fixed the type, or ensure manager_user_id is passed as a string.","cause":"The manager_user_id field is now a string in v3.2.1+ but the backend may return an integer.","error":"pydantic_core._pydantic_core.ValidationError: 1 validation error for User\nmanager_user_id\n  Input should be a valid integer"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}