Config_data in a Python Middleware

How can we use config_data in a Python Auth Middleware?

Is that the correct way to obtain custom data from the Api Definition?

Please advice.

Yes, it is the correct way to get at this data, I think to get it you can just access the spec object:

def MyAuthMiddleware(request, session, metadata, spec):
    configData = spec.config_data

    // Continue code here...
    return request, session, metadata

Looking at this post, I may have spoken to soon and it may not be available in the spec object, but you do have access to the API ID.

What you could do is fetch the API ID in the middleware using the dashboard or gateway REST API, then cache it so you can look it up quickly on the next request.

Your second response it’s a great idea. I spent two days thinking about it, and it didnt occur to me.
Thanks much, please do try to include the config_data in Python. Python offer way more capabilities than JS

1 Like

Hi, this was recently posted by another user, in case you want to track the progress on this feature request:


Hehe, thank you Matias, we worked together on this PR. I’m aware!

1 Like