Authentication
This guide explains how to authenticate with the 1WorldSync Content1 API.
Authentication Credentials
To use the 1WorldSync Content1 API, you need the following credentials:
App ID: Your application identifier provided by 1WorldSync
Secret Key: Your secret key provided by 1WorldSync
GLN (optional): Global Location Number for the user
Setting Up Authentication
There are two ways to set up authentication:
Direct initialization:
from oneworldsync import Content1Client client = Content1Client( app_id='your_app_id', secret_key='your_secret_key', gln='your_gln' # Optional )
Environment variables:
Set the following environment variables:
ONEWORLDSYNC_APP_ID=your_app_id ONEWORLDSYNC_SECRET_KEY=your_secret_key ONEWORLDSYNC_USER_GLN=your_gln # Optional ONEWORLDSYNC_CONTENT1_API_URL=https://content1-api.1worldsync.com # Optional
Then initialize the client without parameters:
from oneworldsync import Content1Client client = Content1Client()
Using a .env File
For development, you can use a .env file to store your credentials:
Create a .env file in your project directory:
ONEWORLDSYNC_APP_ID=your_app_id ONEWORLDSYNC_SECRET_KEY=your_secret_key ONEWORLDSYNC_USER_GLN=your_gln ONEWORLDSYNC_CONTENT1_API_URL=https://content1-api.1worldsync.com
Load the environment variables using the python-dotenv package:
import os from dotenv import load_dotenv from oneworldsync import Content1Client # Load environment variables from .env file load_dotenv() # Initialize client using environment variables client = Content1Client()
Authentication Process
The 1WorldSync Content1 API uses HMAC authentication. The client handles this process automatically:
The client generates a timestamp for the request
The client constructs the URI with the timestamp
The client generates a hash code using the secret key and URI
The client adds the app ID, hash code, and GLN (if provided) to the request headers
For more details on the HMAC authentication process, refer to the 1WorldSync Content1 API HMAC Guide.