otpless-auth-sdk
Project description
Merchant Integration Documentation(Backend Python Auth SDK)
A. 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:
verify_code(code, 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, 'iss': 'https://otpless.com', 'sub': '547', 'aud': 'kp******', 'exp': 1697189497000, 'iat': 1697185897000, 'auth_time': 1697205696, 'phone_number': '+919******', 'email': 'dh******@gmail.com', 'name': 'Dev** From OTP-less', 'authentication_details': {'phone': {'mode': 'WHATSAPP', 'phone_number': '93******', 'country_code': '+91', 'auth_state': 'verified'}, 'email': {'email': 'dev*****', 'mode': 'APPLE_EMAIL', 'auth_state': 'verified'}}}
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=None)
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, 'iss': 'https://otpless.com', 'sub': '547', 'aud': 'kp******', 'exp': 1697189497000, 'iat': 1697185897000, 'auth_time': 1697205696, 'phone_number': '+919******', 'email': 'dh******@gmail.com', 'name': 'Dev** From OTP-less', 'authentication_details': {'phone': {'mode': 'WHATSAPP', 'phone_number': '93******', 'country_code': '+91', 'auth_state': 'verified'}, 'email': {'email': 'dev*****', 'mode': 'APPLE_EMAIL', 'auth_state': 'verified'}}}
UserDetail Object Fields:
success(boolean): This will betruein case of method successfully performed operation.
>iss(String, required): The issuer, which should be "https://otpless.com."
>sub(String, required): The subject, typically the user ID.
>aud(String, required): The audience, your OTPLess Client ID.
>exp(Long, required): The expiration time of the token.
>iat(Long, required): The issuance time of the token.
>authTime(Long, required): The time when authentication was completed.
>phoneNumber(String, required): The user's phone number.
>
>name(String, required): The user's full name.
>authenticationDetails(AuthenticationDetails, required): Authentication details containing information about phone verification and email verification.
AuthenticationDetails Object Fields:
phone (PhoneAuthentication, required): Information about phone verification.
email (EmailAuthentication, required): Information about email verification.
PhoneAuthentication Object Fields:
mode (String): The mode of phone verification.
phoneNumber (String): The verified phone number.
countryCode (String): The country code of the phone number.
authState (String): The authentication state of the phone number.
EmailAuthentication Object Fields:
email (String): The verified email address.
mode (String): The mode of email verification.
authState (String): The authentication state of the email.
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(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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file OTPLessAuthSDK-0.1.2.tar.gz.
File metadata
- Download URL: OTPLessAuthSDK-0.1.2.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23bd47f935c003aecf258b8726fc283e55deecf947d3fed25a946242136145e7
|
|
| MD5 |
21f22e29a7f818ec10773492a578dfaf
|
|
| BLAKE2b-256 |
300957fc22146ab163d0c991a0fc8d38e05423d3606607d7667eaff12f0432ab
|
File details
Details for the file OTPLessAuthSDK-0.1.2-py3-none-any.whl.
File metadata
- Download URL: OTPLessAuthSDK-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3ccc87eca106b9dedbe0d10f86e22356a244b4a501e5969197cb76d1e017b1a
|
|
| MD5 |
3ac28c1b99750e563b50b442b3f87472
|
|
| BLAKE2b-256 |
eb4bc14686f3b11e6c00c607193c70c9c093e13ecf571e148422a372fe045aa1
|