"""
Quick script to generate Base64 encoded credentials for Postman
"""

import base64

print("\n" + "="*70)
print("M-PESA AUTHORIZATION HEADER GENERATOR")
print("="*70)

# Get credentials from user
consumer_key = input("\nEnter your Consumer Key: ").strip()
consumer_secret = input("Enter your Consumer Secret: ").strip()

if not consumer_key or not consumer_secret:
    print("\n✗ Error: Both Consumer Key and Secret are required")
    exit(1)

# Generate Basic Auth header
credentials = f"{consumer_key}:{consumer_secret}"
encoded_credentials = base64.b64encode(credentials.encode()).decode()

print("\n" + "="*70)
print("GENERATED AUTHORIZATION HEADER")
print("="*70)

print("\nFor Postman - Step 1 (Get Access Token):")
print("-" * 70)
print(f"Authorization: Basic {encoded_credentials}")

print("\n\nFull Header Configuration:")
print("-" * 70)
print("Key: Authorization")
print(f"Value: Basic {encoded_credentials}")

print("\n\nCopy this value for Postman:")
print("-" * 70)
print(f"Basic {encoded_credentials}")

print("\n" + "="*70)
print("\nNext Steps:")
print("1. Open Postman")
print("2. Create a GET request to:")
print("   https://api.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials")
print("3. Add header: Authorization = Basic {encoded}")
print("4. Send request to get access token")
print("="*70 + "\n")
