/
Client SDK for Python

NOTE: Trivore ID Documentation has moved to https://trivoreid.com

The content on this site IS OUT OF DATE!

This space has been archived!

Please go ahead to the new site!

Client SDK for Python

Python Prerequisites

There are two versions of Client SDK for Python - core and extension. Core covers REST API requests for users, profile, groups, namespases and data storages, and also allows user to send e-mail and SMS messages. The rest of the APIs are covered in extension client.

To install core version use:

pip install requests pip install trivoreid

For an extension client use:

pip install requests pip install trivoreid-extension

How to start

There are two ways to start: using Management API or OpenID credentials.
Configurations for both can be defined in the configuration file or straight in the function. Obviously, for production use, only select secure methods.

Properties file

All credentials will be taken from the properties file. The default path is: /etc/trivoreid/client_sdk.properties.

client_sdk.properties
# Please, replace with proper values to authorize access to the service. # Must be defined for all types of authorization service.address=<placeholder> # For the Password Grant authentication oidc.client.id=<placeholder> oidc.client.secret=<placeholder> password.grant.username=<placeholder> password.grant.password=<placeholder> # OAuth2 oidc.client.redirect.uri=<placeholder> # Management API mgmtapi.id=<placeholder> mgmtapi.secret=<placeholder> # default path name # /etc/trivoreid/client_sdk.properties

Management API

client_sdk.properties

Start TrivoreID SDK

example.py

OpenID Client

The configurations for the authorization, token, scopes and userinfo endpoints can be found in '<server-url>/.well-known/openid-configuration' url.

For implementing OAuth2 for the sdk, use requests_oauthlib.OAuth2Session.
Example of the OAuth2.

example.py

Password Grant

NB! It is strongly recommended to avoid using Password Grant due to security reasons.

Password grant is disabled for the OIDS Client by default. Ask administrator to enable it in order to use.

client_sdk.properties



example.py

OIDC User

OpenID Client SDK and Password Grant give access to the user's own authorized user profile.

This gives us:

Exceptions

TrivoreIDException

Exception is thrown when network or TrivoreID failure occurred. The exception contains error code of the response that allows to handle errors individually.

TrivoreIDSDKException

Exception is thrown when TrivoreID SDK is incorrectly used.





Related content

NOTE: Trivore ID Documentation has moved to https://trivoreid.com

The content on this site IS OUT OF DATE!

This space has been archived!