10.3 Configure Python Applications
The python-oracledb driver supports two approaches for propagating the end-user security context payload from your Python application to the database: API extension methods and a configuration-driven Service Provider Interface (SPI). API calls take precedence over provider-based configurations.
10.3.1 Use the API Extension Methods
If you want to supply the end-user security context payload directly in your application code, use the API extension methods.
The python-oracledb driver extends the standard Python Database API with
the Connection methods to set and clear the end-user security
context payload. Currently, you can use this feature only in python-oracledb's Thin
mode.
To supply the security context payload using the python-oracledb driver, perform the following tasks.
Note:
If no end-user identity is present, the plug-in does not attach the end-user security context payload, and the application receives a least-privileged connection or session (standard behavior) and no error is thrown.10.3.2 Use the Service Provider Interface
The Service Provider Interface (SPI) approach enables your Python application to supply the end-user security context payload with no code changes to your SQL or Object Relational Mapping (ORM) layer.
The python-oracledb driver's end_user_sec_provider
plug-in acts as the SPI provider. By importing the plug-in and adding a
configuration block to your application's database settings, you can enable your
application to automatically propagate the security context payload on every
database operation. The plug-in supports both the
client_credentials and on_behalf_of (OBO)
authentication flows for Microsoft Entra ID, and the
client_credentials flow for OCI IAM.
To supply the security context payload using the SPI approach, perform the following tasks.