Create session cookie with Python API


#1

Hi,

Just started looking into using the Okta API, however using the community supported Python SDK. I’m having issues with creating a session cookie using the API, to then pass into a session request, and was wondering if anyone could help shed some light on this?

Rough code so far:

from okta import SessionsClient
from requests import Session
from zeep import Client
from zeep.transports import Transport

from pprint import pprint

url = "https://example.okta.com"
token = "<example-token>"
username = "<username>"
password = "<password>"

oktaClient = SessionsClient(url, token)

oktaSessionID = oktaClient.create_session(username, password)
print (oktaSessionID)

pprint(vars(oktaSessionID))

session = Session()
session.auth = oktaSessionID.cookieToken # <- fails here
client = Client(wsdl, transport=Transport(session=session))

The output of the create_session using pprint returns the following, which for some reason returns a None for cookieToken?

{
‘cookieToken’: None,
‘cookieTokenUrl’: None,
‘id’: ‘’,
‘mfaActive’: None,
‘userId’: ‘’
}

Thanks in advance!