Login

Login a user by generating a token

from smart_prospective_api import SPApi, APIError

# Note: The public key starts by "pub_" & The secret key starts by "sec_"
PUBLIC_KEY = "pub_XXXXXX"
PRIVATE_KEY = "sec_XXXXXX"

try:
    # Setup the API credencial (do not perform any request at this moment)
    sp_api = SPApi(PUBLIC_KEY, PRIVATE_KEY)

    # Login the user according the private & public key
    # The login is automatic, so DON'T NEED TO CALL IT MANUALLY
    print(f"Token: {sp_api.login()}")
    
    # Logout the account, more safe to use it, to avoid potential attacks
    sp_api.logout()
except APIError as e:
    print(f"Failure using the Smart Prospective API: {e}")
curl --location --request POST 'https://app.smartprospective.com/api/login' \
--form 'api_public_key="pub_XXXXXX"' \
--form 'api_secret_key="sec_XXXXXX"'

Note: The generated token will be used for most of the request