Using Okta with Flask and Connexion

I followed your Flask sample application for a new Python API and it worked beautifully. However, I wanted to be able to use Connexion which generates the boilerplate code from a swagger.yml and I simply define the methods for each endpoint. I tried using the @oidc.accept_token before the endpoint methods, however, the Connexion code that loads the endpoint module must not do something as expected as I get “TypeError: init() missing 1 required positional argument: ‘import_name’” when trying to call OpenIDConnect to get the oidc object.

I have access to the headers in the endpoint methods, so I could work with the bearer token inside the methods.

So my question is: is there an alternative to the @oidc.accept_token strategy defined in the Okta Python library that I could use, or perhaps something simple that I can do to get the oidc object and be able to use the accept_token as demonstrated in your example file?

You can find my code at GitHub here: https://github.com/rkamradt/flaskapi
The main.py is the main module and the winePairing.py is the endpoint methods.

Alternatively, since the swagger.yml is in openapi format, can I define a jwt section in the securitySchemes section? If so, what would the decode_token method look like?

@rkamradt Hi, we may need to take a look of the error you encountered in your code. Can you please open a support ticket through an email to support@okta.com with this issue? One of our Developer Support Engineers will take the case.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.