Skip to main content

Python

Initial Setup

The LoginID Server SDK enables you to perform operations which are protected, enabling much more robust functionality for your users.

Create API Credential on the Dashboard

An application must be created on the LoginID Dashboard in order to correctly configure the Server SDK.

Once logged into the dashboard, navigate to the Applications tab in the sidebar, select “Add Application,” and select Management.

In the resulting form, you must create a name for your application and provide an API credential to be associated with this application. If you have already created an application, we suggest using the naming convention of “{my-app) server.”

When adding the API credential, you can either upload your own public key, or have us generate a key pair on your behalf.

note

All API calls made from a Management integration type require an API Service Token

Add SDK to Existing Application

git clone git@github.com:loginid1/python-sdk.git
cd python-sdk

pip install .

Create an SDK Instance

from loginid import LoginID

lid = LoginID(client_id=CLIENT_ID, private_key=PRIVATE_KEY)
note

If using a custom base_url, you can initialize the SDK with that base_url. Otherwise, it will default to the main LoginID production environment.

Application API Reference

LoginID Class

Constructor

This server SDK leverages either a web or mobile application and requires an API credential to be assigned to that integration.

Helper Functions

generate_service_token

Generate a service token, to be used when making protected API calls. Not required when calling other methods with the server SDK.

verify_token

Verify a JWT returned upon user authentication.


generate_tx_auth_token

Generates the bearer token to be used in the transaction confirmation flow, as it has a specific format slightly different from the standard service tokens. This function generates that token. If calling the create_tx method, this function does not need to be called first.

create_tx

Create a transaction ID. This is typically the first step of the transaction confirmation flow.

The transaction id if no error

verify_transaction

Verify the jwt returned in the confirmTransaction flow.

Management API Reference

LoginIdManagement Constructor

This server SDK can be used with a management application and requires an API credential to be assigned to that integration. All calls made from this SDK are intended to be backend-to-backend calls, as the operations are sensitive.

generate_code

Generate a code, which can be used for a variety of purposes. Check out the guides section for how various ways these codes can be used.

authorize_code

Authorize a code which was previously generated through the generate_code method.

wait_code

Submit a code and wait for it to be authorized. You can use this method when leveraging the code to authenticate a user.

invalidate_all_codes

Invalidate all codes of a given type for a specific user.


Credential Management Functions

get_credentials

Get an exhaustive list of credentials for a given user.

rename_credential

Rename a credential given the credential id.

revoke_credential

Revoke a credential so it can longer be used.

User Management Functions

get_user

Get the user profile given a username

deactivate_user_by_id

Temporarily deactivate a user account.

activate_use_by_id

Re-activate a previously deactivated user profile.

delete_by_user_id

Deletes a user profile based on a user_id as the input. This operation cannot be undone.

delete_by_username

Deletes a user profile based on a username as the input. This operation cannot be undone.