How to authenticate with OCI using OIDC in serverless environments (AWS Lambda/Azure Functions) with Python SDK?
Background
I'm trying to implement a solution where code running in serverless environments (AWS Lambda or Azure Functions) needs to access Oracle Cloud Infrastructure (OCI) resources using the Python SDK. I need to use OpenID Connect (OIDC) to obtain temporary credentials for authenticating with OCI.
Problem
While I understand how to implement OIDC-based authentication with AWS (using OIDC to get an ID token, then exchanging it for AWS STS credentials), I'm struggling to find equivalent documentation or methods for OCI when using the Python SDK specifically.
What I've done so far:
- Successfully added a custom OIDC Identity Provider in the OCI Identity domain following the Add a social identity provider documentation
Image of my OIDC Idp - Reviewed OCI documentation on Session Token-Based Authentication
- Looked into Python SDK documentation for authentication methods
Specific challenges:
- The OCI documentation for Python SDK authentication with session tokens redirects to CLI-based authentication
- I cannot use CLI-based authentication methods since I'm operating in serverless environments (AWS Lambda/Azure Functions)
- I need to understand how to establish a connection between OIDC tokens and OCI session tokens programmatically in Python
- I specifically need a solution that works with the OCI Python SDK
Questions:
- Is there a way to exchange OIDC tokens for OCI session tokens similar to how AWS STS works using the Python SDK?
- How can I authenticate with OCI Python SDK in a serverless environment without relying on CLI?
- Are there any code examples showing how to use OIDC tokens to authenticate with OCI Python SDK?
Technical environment:
- Serverless platforms: AWS Lambda and Azure Functions
- SDK: OCI Python SDK
- Authentication method needed: OIDC-based (without CLI dependency)
Any guidance, documentation references, or code examples for implementing this with the Python SDK would be greatly appreciated!