How to Get your Basic Auth Token - Python Test Example

You can create a base64-encoded string for a ClientID:SecretKey in Python using the base64 module. Here’s how you can do it:

You should replace "API_Client_ID" and "API_Secret_Key" with the actual API Client ID and API Secret Key values.


import base64

def encode_credentials(API_Client_ID, API_Secret_Key):
    # Combine the API_Client_ID and API_Secret_Key with a colon
    credentials = f"{API_Client_ID}:{API_Secret_Key}"
    
    # Convert the string to bytes
    credentials_bytes = credentials.encode('utf-8')
    
    # Base64 encode the bytes
    base64_bytes = base64.b64encode(credentials_bytes)
    
    # Convert the base64 bytes back to a string
    base64_string = base64_bytes.decode('utf-8')
    
    return base64_string

# Example usage


API_Client_ID = "1234567890abcd"
API_Secret_Key = "QSDFGH456fcgvhbERTYbhjnb"


Basic_encoded_credentials = encode_credentials(API_Client_ID, API_Secret_Key)
print(Basic_encoded_credentials)