Generate Token for Web Integration

Required Class: Web API Class

Generating a Token for Web Integration

To use our web integration, you must generate a web token for every instance of the widget you run. You can generate a token with this library by editing the sample code below with your own parameters:

from smile_id_core import WebApi, ServerError

# Initialize
partner_id = "<Put your partner ID here>"; #login to the Smile ID portal to view your partner id
default_callback = "<Put your default callback url here>";
api_key = "<Put your API key here>"; # copy your API key from the Smile ID portal
sid_server = <0 | 1>; # Use 0 for the sandbox server, use 1 for production server

connection = WebApi(partner_id,default_callback,api_key,sid_server)

# Create required request parameters
user_id = "<put your unique ID for the user here>"; # Set your unique user_id
job_id = "<put your unique job ID here>"; # Set the unique job_id
product = "<put product name here>"; # Choose one of 'authentication', 'basic_kyc', 'smartselfie', 'biometric_kyc', 'enhanced_kyc', 'doc_verification'

# Generate the web token
try:
    response = connection.get_web_token(user_id,job_id,product)
except ValueError:
    # some of your params entered for a job are not valid or missing
    print("handle ValueError")
except ServerError:
    # Server returned an error
    print("handle ServerError")
except FileNotFoundError:
    # Sent a file which could not be found
    print("handle FileNotFoundError")

Response

The response will return a json that contains the following:

{
  "success": true,
  "token": "<token string>"
}

For a comprehensive guide on using the web integration, check the Usage section of the Web Integration documentation.

Last updated