Skip to main content

otpless-auth-sdk

Project description

Merchant Integration Documentation(Backend Python Auth SDK)


A. OTPLessAuth Dependency

install Below dependency in your project's

pip install OTPLessAuthSDK

you can also get latest version of dependency at https://pypi.org/project/OTPLessAuthSDK


B. OTPLessAuth class

The OTPLessAuth class provides methods to integrate OTPLess authentication into your Python backend application. This documentation explains the usage of the class and its methods.

Methods:


1. decodeIdToken


This method help to resolve idToken(JWT token) which is issued by OTPLess which return user detail from that token also this method verify that token is valid, token should not expired and issued by only otpless.com

Method Signature:
decode_id_token(id_token, client_id, client_secret, audience=None)

Method Params:

Params Data type Mandatory Constraints Remarks
idToken String true idToken which is JWT token which you get from OTPLess by exchange code API
clientId String true Your OTPLess Client Id
clientSecret String true Your OTPLess Client Secret

Return

Return: Object Name: UserDetail

{'success': True, 'auth_time': 1697649943, 'phone_number': '+9193******', 'email': 'dev***@gmail.com', 'name': 'Devloper From OTP-less', 'country_code': '+91', 'national_phone_number': '9313******'}

2. verify code


This method help to resolve code which is return from OTPLess which will return user detail from that code also this method verify that code is valid, code should not expired and issued by only otpless.com

Method Signature:
verify_code(code, client_id, client_secret, audience)

Method Params:

Params Data type Mandatory Constraints Remarks
code String true code which you get from OTPLess
clientId String true Your OTPLess Client Id
clientSecret String true Your OTPLess Client Secret

Return

Return: Object Name: UserDetail

{'success': True, 'auth_time': 1697649943, 'phone_number': '+9193******', 'email': 'dev***@gmail.com', 'name': 'Devloper From OTP-less', 'country_code': '+91', 'national_phone_number': '9313******'}

3. Verify Auth Token


This method help to resolve token which is issued by OTPLess which return user detail from that token also this method verify that token is valid, token should not expired and issued by only otpless.com

Method Signature:
verify_token(token, client_id, client_secret)

Method Params:

Params Data type Mandatory Constraints Remarks
token String true token which you get from OTPLess
clientId String true Your OTPLess Client Id
clientSecret String true Your OTPLess Client Secret

Return

Return: Object Name: UserDetail

{'success': True, 'auth_time': 1697649943, 'phone_number': '+9193******', 'email': 'dev***@gmail.com', 'name': 'Devloper From OTP-less', 'country_code': '+91', 'national_phone_number': '9313******'}

4. Generate Magic link


The Authorization Endpoint initiates the authentication process by sending a magic link to the user's WhatsApp or email, based on the provided contact information. This link is used to verify the identity of the user. Upon the user's action on this link, they are redirected to the specified URI with an authorization code included in the redirection.

Method Signature:
generate_magic_link(mobile_number, email, client_id, client_secret,redirect_uri,channel)

Method Params:

Params Data type Mandatory Constraints Remarks
channel String false if no channel given WHATSAPP is chosen as default WHATSAPP/SMS
mobile_number String false At least one required The user's mobile number for authentication in the format: country code + number (e.g., 91XXXXXXXXXX)
email String false At least one required The user's email address for authentication.
redirect_uri String true The URL to which the user will be redirected after authentication. This should be URL-encoded
clientId String true Your OTPLess Client Id
clientSecret String true Your OTPLess Client Secret

Return

Return: Object Name: RquestIds

{'mobile_request_id': '72bf8ccdb56949c18fa141452c3b42a6', 'email_request_id': 'e3600742ff6049de85d0fe60995beefe', 'success': True}

UserDetail Object Fields:

success (boolean): This will be true in case of method successfully performed operation.
> authTime (Long, required): The time when authentication was completed.
> phoneNumber (String, required): The user's phone number.
> countryCode (String, required): The country code of user's phone number.
> nationalPhoneNumber (String, required): The user's phone number without country code.
> email (String, required): The user's email address.
> name (String, required): The user's full name.

Error case:

success (boolean): This will be false. The method is failed to perform.
errorMessage (String): The message contains error information.

Example of usage

import OTPLessAuthSdk

# Setup necessary parameters
client_id = "your_client_id"
client_secret = "your_client_secret"
code = "your_id_token_here"
audience = None

# Use the verify_code function to verify the code and get user details
try:
    user_details = OTPLessAuthSDK.UserDetail.verify_code(code, client_id, client_secret, audience)


    print(user_details.success)
    print(user_details.auth_time)
    print(user_details.phone_number)
    print(user_details.email)
    print(user_details.name)
    print(user_details.country_code)
    print(user_details.national_phone_number)


    print(f"User details: {user_details}")
except Exception as e:
    print(f"An error occurred: {e}")

This method allows you to decode and verify OTPLess ID tokens and retrieve user information for integration into your backend Python application.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

OTPLessAuthSDK-0.2.3.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

OTPLessAuthSDK-0.2.3-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file OTPLessAuthSDK-0.2.3.tar.gz.

File metadata

  • Download URL: OTPLessAuthSDK-0.2.3.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for OTPLessAuthSDK-0.2.3.tar.gz
Algorithm Hash digest
SHA256 f03a885c32feb4cba68d072810c15d8562d81240be35430c0f85cb6956850246
MD5 4bcbccaa371e7c069931c5f778d9dc9c
BLAKE2b-256 56c5393b2b36472600b32555ebf98d00835374ede5845f8e5fef74a610a9f207

See more details on using hashes here.

File details

Details for the file OTPLessAuthSDK-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: OTPLessAuthSDK-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for OTPLessAuthSDK-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0b5b4afcb033d0a0d1533aa4d0fa1a731c46ad64bc5070add3859f12edcfb7e5
MD5 c56e89c6a0eed3a7596952a520b5af1c
BLAKE2b-256 d82bcac4f332b86e231f5dddd676c855e6b6c8de63438d398290b22123fca0da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page