LogonLabs Python
The official LogonLabs Python library.
Download
- First time install
pip install logonlabs-python
- If you have installed the package already, please upgrade it.
pip install --upgrade logonlabs-python
LogonLabs API
-
Prior to coding, some configuration is required at https://app.logonlabs.com/app/#app-settings
-
For the full Developer Documentation please visit: https://app.logonlabs.com/api/
Instantiating a new client
- Your
APP_IDcan be found in App Settings. APP_SECRETSare configured here.- The
LOGONLABS_API_ENDPOINTshould be set tohttps://api.logonlabs.com.
Create a new instance of LogonClient.
from logonlabs.client import Logonlabs
logonClient = Logonlabs('{APP_ID}', '{APP_SECRETS}', '{LOGONLABS_API_ENDPOINT}')
SSO Login QuickStart
The StartLogin function in the JS library begins the LogonLabs managed SSO process.
Further documentation on starting the login process via our JavaScript client can be found at our GitHub page here. The following example demonstrates what to do once the
callback Urlhas been used by our system to redirect the user back to your page:
request_headers = self.headers
token = request_headers["token"]
response = logonClient.validateLogin(token)
data = response.json()
if data['event_success']:
#authentication and validation succeeded. proceed with post-auth workflows (ie, create a user session token for your system).
Python Only Workflow
The following workflow is required if you're using Python to process all transaction requests. If this does not apply to you, please refer to the SSO Login QuickStart section.
Step 1 - StartLogin
This call begins the LogonLabs managed SSO process. The client_data property is optional and is used to pass any data that is required after validating the request. The tags property is an Array of type Tag which is a simple object representing a key/value pair. The force_reauthentication property is an optional method to attempt or force an Identity Provider to reauthenticate with the user.
identity_provider = '{string}' # one of the following ['microsoft','google','facebook','linkedin','slack','twitter','github','quickbooks','onelogin','okta','apple','basecamp','dropbox','fitbit','planningcenter','twitch']
identity_provider_id = '{string}' # require identity_provider or identity_provider_id
client_data = '{string}'
tags = [{'example-key': 'example-value'}]
redirect = False
callback_url = 'https://example.com'
destination_url = 'https://example.com'
force_reauthentication = '{string}' # one of the following ['off', 'attempt', 'force']
response = logonClient.startLogin(identity_provider, identity_provider_id, "example@emailaddress.com", client_data, callback_url, destination_url, tags, force_reauthentication)
redirect_url = response.headers['Location']
The redirect_url property returned should be redirected to by the application. Upon submitting their credentials, users will be redirected to the callback_url set within the application settings at https://logonlabs.com/app/#/app-settings.
Step 2 - ValidateLogin
This method is used to validate the results of the login attempt. query_token corresponds to the query parameter with the name token appended to the callback url specified for your app.
The response contains all details of the login and the user has now completed the SSO workflow. If there is any additional information to add, UpdateEvent can be called on the event_id returned.
response = logonClient.validateLogin('{token}')
data = response.json()
if data['event_success']:
#success
else:
validation_details = data['validation_details']
if validation_details['domain_validation'] == 'fail':
#provider used was not enabled for the domain of the user that was authenticated
if validation_details['ip_validation'] == 'fail' or validation_details['geo_validation'] == 'fail' or validation_details['time_validation'] == 'fail':
#validation failed via restriction settings for the app
CreateEvent
The CreateEvent method allows one to create events that are outside of our SSO workflows.
local_validation = '{string}' # one of the following ['Pass', 'Fail', 'NotApplicable']
tags = [{'example-key': 'example-value'}]
event_type = '{string}' # one of the following ['LocalLogin', 'LocalLogout']
response = logonClient.createEvent(event_type, True, local_validation, "{EMAIL_ADDRESS}", "{IP_ADDRESS}", "{USER_AGENT}", "{FIRST_NAME}", "{LAST_NAME}", tags)
OAuth Tokens
Optionally, Identity Providers can be configured to return OAuth Tokens. These tokens can be used to make API requests on behalf of the user by the OAuth protocol. In order to enable this feature Return Authorization Data must be enabled for your Provider. For more information visit the Refresh Tokens Documentation.
RefreshToken
RefreshToken renews the Access Token via the Refresh Token.
identityProviderId = '{string}' # can be retrieved by calling GetProviders
token = '{string}' # returned by authorization_data_tokens.refresh_token in the ValidateLogin Response
response = logonClient.refreshToken(identityProviderId, token)
refresh_token = response.authorization_data_tokens.refresh_token
RevokeToken
RevokeToken invalidates the Token passed
identityProviderId = '{string}' # can be retrieved by calling GetProviders
token = '{string}' # returned by refresh_token or access_token from authorization_data_tokens in the ValidateLogin Response
response = logonClient.revokeToken(identityProviderId, token)
Helper Methods
GetProviders
This method is used to retrieve a list of all providers enabled for the application. If an email address is passed to the method, it will return the list of providers available for that email domain.
response = logonClient.getProviders("example@emailaddress.com")
data = response.json()
social_identity_providers = data['social_identity_providers']
for provider in social_identity_providers:
#each individual providers available for this email address
enterprise_identity_providers = data['enterprise_identity_providers']
for enterpriseProvider in enterprise_identity_providers:
#each enterprise providers available for this email address
Metadata
Release files for logonlabs-python 1.7.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| logonlabs-python-1.7.7.tar.gz | 5.1 kB | Without provenance | Details for logonlabs-python-1.7.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| logonlabs_python-1.7.7-py3-none-any.whl | Python 3 | none | any | Details for logonlabs_python-1.7.7-py3-none-any.whl |
Total release size: 11.1 kB
Release files / logonlabs-python-1.7.7.tar.gz
| Download URL | logonlabs-python-1.7.7.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67f9c4561f4bb106350596117fd63a08fbc750492689417fcdf9a2546d12027d
|
|
BLAKE2b-256 checksum How to use checksums |
c3f9a4d9d11019161ef8fa962185550841b7a84202984c7ee90728e72c5ebad4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2
|
Release files / logonlabs_python-1.7.7-py3-none-any.whl
| Download URL | logonlabs_python-1.7.7-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d8b4edc0c7060ae0317d159d53ee65a69340052771ba69c9197bfb0abd8c23b
|
|
BLAKE2b-256 checksum How to use checksums |
05394c65c77e9af5f0d6cd9b84f3876e75d60f7621f4086aee35094a1e359e77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.2
|
Security for logonlabs-python 1.7.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.