Hi,
I’m trying to call the Create User Without Credentials API from within a Python app. This works fine when using Postman or Insomnia with the API token assigned to the app. However, in Python 3.6.5 I get the following error:
Invalid header name ‘Authorization:’
I am using the requests module. Here is my code (API key is retrieved from env variable and user data is passed into the enclosing function as parameters). I have removed error trapping, comments etc:
api_token = settings.OKTA_API_TOKEN
endpoint = settings.OKTA_NEW_USER_API_URL
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization:": f"SSWS {api_token}",
}
payload = {
"profile": {
"firstName": first_name,
"lastName": last_name,
"email": email,
"login": email,
"mobilePhone": mobile_phone
}
}
# FAILS HERE => ValueError: Invalid header name b'Authorization:'
response = requests.post(
url=endpoint,
headers=headers,
json=payload,
)
If I try to move the Auth details into the requests.post’s auth parameter, no matter how I set the tuple, I cannot get it to accept the token - I always get a 403 with an invalid session error in the errorSummary return value)
Could somebody advise as to what I am doing wrong above? Many thanks.