Skip to main content

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.

Metadata

Release files for nice-auth 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nice-auth 0.1.5
File Size Uploaded
nice_auth-0.1.5.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nice-auth 0.1.5
File Interpreter ABI Platform
nice_auth-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / nice_auth-0.1.5.tar.gz

Download URL nice_auth-0.1.5.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d07b1d35cf6b3b6145b7f5ac388a4c230622bdf729a60f59b7fe76f20360bcae
BLAKE2b-256 checksum
How to use checksums
da09d81b3cce6320873d256c448d03d156d05f75aead543c3c30f810dcc65fe6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.8.18

Release files / nice_auth-0.1.5-py3-none-any.whl

Download URL nice_auth-0.1.5-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15e79f12dd8594892a497bd42900c9d009b667c5dd5c48cbf424d1db40b88279
BLAKE2b-256 checksum
How to use checksums
d57a1cdb365caa5141b2b3622d6e331fa4a2582cf40c659e6ec5d2f068b78bf9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.8.18

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page