A Python library for NICE authentication
Project description
python-nice-auth
A Python library for NICE authentication.
Current version: 0.1.5
Overview
python-nice-auth
is a Python library that provides an interface for interacting with the NICE authentication API. It supports obtaining tokens, generating encrypted tokens, and creating URLs for NICE authentication services.
Installation
To install the library, use pip:
pip install -U nice-auth
Configuration
Before using the library, you need to set up the necessary configuration values. Add the following environment variables to your .env file or set them directly in your environment:
NICE_AUTH_BASE_URL=https://svc.niceapi.co.kr:22001
NICE_CLIENT_ID=your_client_id
NICE_CLIENT_SECRET=your_client_secret
NICE_PRODUCT_ID=your_product_id
NICE_RETURN_URL=https://yourdomain.com/verify
NICE_AUTHTYPE=M
NICE_POPUPYN=N
Usage
Initializing the Service
First, you need to initialize the NiceAuthService with the necessary configuration values:
from nice_auth.services import NiceAuthService
# Initialize the service with configuration values
nice_auth_service = NiceAuthService(
base_url="https://nice.checkplus.co.kr",
client_id="your_client_id",
client_secret="your_client_secret",
product_id="your_product_id",
return_url="your_return_url",
authtype="your_authtype",
popupyn="your_popupyn"
)
Getting a Token
You can obtain a token by calling the get_token method:
access_token = nice_auth_service.get_token()
Getting an Encrypted Token
To get an encrypted token, use the get_encrypted_token method:
encrypted_token_data, req_dtim, req_no = nice_auth_service.get_encrypted_token(access_token)
Getting NICE Auth Data
To get the necessary data for NICE authentication, use the get_nice_auth method:
auth_data = nice_auth_service.get_nice_auth()
Generating NICE Auth URL
Finally, you can generate the NICE authentication URL:
nice_auth_url = nice_auth_service.get_nice_auth_url()
Verifying Authentication Result
To verify the authentication result, use the verify_auth_result method:
auth_result = nice_auth_service.verify_auth_result(enc_data, key, iv)
Complete Example
Here is a complete example of using the library:
from nice_auth.services import NiceAuthService
# Initialize the service with configuration values
nice_auth_service = NiceAuthService(
base_url="https://nice.checkplus.co.kr",
client_id="your_client_id",
client_secret="your_client_secret",
product_id="your_product_id",
return_url="your_return_url",
authtype="your_authtype",
popupyn="your_popupyn"
)
# Get a token
access_token = nice_auth_service.get_token()
# Get an encrypted token
encrypted_token_data, req_dtim, req_no = nice_auth_service.get_encrypted_token(access_token)
# Generate NICE Auth URL
nice_auth_url = nice_auth_service.get_nice_auth_url()
print(f"NICE Auth URL: {nice_auth_url}")
License
This project is licensed under the MIT License.
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
Built Distribution
File details
Details for the file nice_auth-0.1.5.tar.gz
.
File metadata
- Download URL: nice_auth-0.1.5.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d07b1d35cf6b3b6145b7f5ac388a4c230622bdf729a60f59b7fe76f20360bcae |
|
MD5 | 7dd04020115c37986a5000b46fb5abfe |
|
BLAKE2b-256 | da09d81b3cce6320873d256c448d03d156d05f75aead543c3c30f810dcc65fe6 |
File details
Details for the file nice_auth-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: nice_auth-0.1.5-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15e79f12dd8594892a497bd42900c9d009b667c5dd5c48cbf424d1db40b88279 |
|
MD5 | e3cb5f7eff7734e3fb49544fbed9d3b9 |
|
BLAKE2b-256 | d57a1cdb365caa5141b2b3622d6e331fa4a2582cf40c659e6ec5d2f068b78bf9 |