okta / okta-sdk-python

Apache License 2.0
234 stars 143 forks source link

Okta HTTP 500 E0000009 Internal Server Error when creating MultifactorEnrollmentPolicy #358

Open delubi-ro opened 1 year ago

delubi-ro commented 1 year ago

SDK version

❯ pip list |grep okta
okta                                2.9.2

Steps to reproduce:

Using the following test-okta.py

from okta.client import Client as OktaClient
from okta import models
import asyncio

async def main():
  client = OktaClient()
  policy = models.MultifactorEnrollmentPolicy({
    "name": "testmfa",
    "status": "ACTIVE",
    "description": "test mfa",
    "type": models.PolicyType.MFA_ENROLL,
    "settings": {
      "type": "AUTHENTICATORS",
      "authenticators": [
        {
            "key": "okta_email",
            "enroll": {
                "self": "OPTIONAL"
            }
        },
        {
            "key": "google_otp",
            "enroll": {
                "self": "OPTIONAL"
            }
        },
        {
            "key": "okta_password",
            "enroll": {
                "self": "REQUIRED"
            }
        }
      ]
    }
  })
  created_policy, _, err = await client.create_policy(policy)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Getting error as

❯ python test-okta.py
2023-04-07 17:37:50,197 - okta-sdk-python - http_client - ERROR - {'message': 'Okta HTTP 500 E0000009 Internal Server Error\n'}
gabrielsroka commented 1 year ago

it looks like there's a bug in the model. this seems to work

from okta.client import Client as OktaClient
from okta import models
import asyncio

async def main():
  client = OktaClient()
  policy = {
    "name": "testmfa3456",
    "status": "ACTIVE",
    "description": "test mfa",
    "type": models.PolicyType.MFA_ENROLL,
    "settings": {
      "type": "AUTHENTICATORS",
      "authenticators": [
        {
            "key": "okta_email",
            "enroll": {
                "self": "OPTIONAL"
            }
        },
        {
            "key": "google_otp",
            "enroll": {
                "self": "OPTIONAL"
            }
        },
        {
            "key": "okta_password",
            "enroll": {
                "self": "REQUIRED"
            }
        }
      ]
    }
  }
  created_policy, r, err = await client.create_policy(policy)
  print(created_policy, r, err)

asyncio.run(main())