Skip to content

Add OAuth 2 client library for Python - #1

Merged
ShimonaR-MC merged 36 commits into
mainfrom
feature/initial-implementation
Oct 23, 2026
Merged

ShimonaR-MC merged 36 commits into
mainfrom
feature/initial-implementation

Conversation

@ShimonaR-MC

@ShimonaR-MC ShimonaR-MC commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Introduces the Mastercard OAuth 2.0 client library for Python, including FAPI 2.0, DPoP, token caching, key management, and integrations for HTTPX, aiohttp, and OpenAPI-generated clients.

Adds opt-in Mastercard sandbox tests for all supported integrations, with manual and scheduled GitHub Actions execution.

See the README for installation, configuration, supported clients, and usage examples.

Jira

Pending Work

Public release and release gates are tracked separately under G1548-11182.

Validation

  • 310 deterministic tests passed
  • Ruff and mypy passed
  • Distribution build, Twine, and wheel checks passed
  • Mastercard sandbox matrix passed for all required client and DPoP combinations
  • SonarQube analysis completed with no security hotspots

Comment thread README.md Resolved
Comment thread src/mastercard_oauth2_client/config.py Resolved
Comment thread src/mastercard_oauth2_client/dpop.py Resolved

@joseph-neeraj joseph-neeraj left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread pyproject.toml
build-backend = "hatchling.build"

[project]
name = "mastercard-oauth2-client"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to book the name mastercard-oauth2-client asap on PyPI (https://pypi.org/project/mastercard-oauth2-client/ returns 404). Once the repo is public, anyone can publish under this name before we do.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean we should publish a prerelease to claim the name, or is there another way to reserve it on PyPI?

@jaaufauvre jaaufauvre Oct 7, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe publish and then make the repo public. Or publish soon enough. I've read something the other day about bots stealing package names like that.

Comment thread pyproject.toml Resolved
Comment thread pyproject.toml Resolved
Comment thread README.md Resolved
Comment thread .github/workflows/live-test.yml Resolved
Comment thread LICENSE Resolved
@ShimonaR-MC

Copy link
Copy Markdown
Collaborator Author

Fix for defect https://mastercard.atlassian.net/browse/G1548-13582 [Python OAuth2 Library] Failed token request is returned as the resource response instead of raising an error. Addressed by cecee4c.

@jaaufauvre
jaaufauvre self-requested a review October 13, 2026 13:04
@ShimonaR-MC

Copy link
Copy Markdown
Collaborator Author

Review comment (offline from Marco): A DPoP challenge from a redirect destination could cause the original request to be sent again.

Fix: The handler now verifies that the response belongs to the request it is handling before retrying the request or storing the returned nonce. Tests cover both same-origin and cross-origin redirects. Addressed by 470c6e1.

@ech0s7r

ech0s7r commented Oct 19, 2026

Copy link
Copy Markdown
Member

Review comment (offline from Marco): A DPoP challenge from a redirect destination could cause the original request to be sent again.

Fix: The handler now verifies that the response belongs to the request it is handling before retrying the request or storing the returned nonce. Tests cover both same-origin and cross-origin redirects. Addressed by 470c6e1.

Thanks @ShimonaR-MC.

@ech0s7r
ech0s7r self-requested a review October 19, 2026 13:04

@Akshaykdubey Akshaykdubey left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ShimonaR-MC
ShimonaR-MC merged commit 61972ed into main Oct 23, 2026
47 checks passed

This branch was successfully deployed

1 active deployment
sandbox — 470c6e1e Deployed Oct 23, 2026 by ShimonaR-MC via openapi-httpx / ec #5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants