Skip to content

Conversation

@lovasoa
Copy link

@lovasoa lovasoa commented Oct 21, 2025

add support for string-encoded expires_in for Azure AD compatibility

While RFC 6749 Section 5.1 describes expires_in as an integer, Microsoft Azure AD returns this value as a string (e.g., "3600" instead of 3600). This non-compliant behavior has been a known issue since at least 2022, yet remains unresolved.

Given that Microsoft Azure AD is one of the largest OAuth 2.0 identity providers globally, rejecting their token responses due to this technical violation creates a barrier to adoption. Many enterprise applications depend on Azure AD for authentication, making this workaround necessary for real-world compatibility.

This change implements a lenient deserializer that accepts both the standard integer format and Azure's string format, ensuring the library works with RFC-compliant providers while maintaining compatibility with Azure. The fix is transparent to users - existing code continues to work without modification - and adds test coverage for both formats.

fixes #191

add support for string-encoded `expires_in` for Azure AD compatibility

While [RFC 6749 Section 5.1](https://tools.ietf.org/html/rfc6749#section-5.1) describes `expires_in` as an integer, Microsoft Azure AD returns this value as a string (e.g., `"3600"` instead of `3600`). This non-compliant behavior has been a [known issue since at least 2022](https://feedback.azure.com/d365community/idea/7772fd95-26e6-ec11-a81b-0022484ee92d), yet remains unresolved.

Given that Microsoft Azure AD is one of the largest OAuth 2.0 identity providers globally, rejecting their token responses due to this technical violation creates a barrier to adoption. Many enterprise applications depend on Azure AD for authentication, making this workaround necessary for real-world compatibility.

This change implements a lenient deserializer that accepts both the standard integer format and Azure's string format, ensuring the library works with RFC-compliant providers while maintaining compatibility with Azure. The fix is transparent to users - existing code continues to work without modification - and adds test coverage for both formats.

fixes ramosbugs#191
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.

Azure Oauth2.0 issue parsing 'expires_in' and potentially others returned from Azure's client_credentials token url

1 participant