OAuth2 Clients: Error in Fetching Clients due to Lifespan fields throwing validation errors
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 178
- Forks
- 96
- Avg merge
- 6d 23h
- Merged PRs (30d)
- 3
Description
Preflight checklist
- I could not find a solution in the existing issues, docs, nor discussions.
- I agree to follow this project's Code of Conduct.
- I have read and am following this repository's Contribution Guidelines.
- I have joined the Ory Community Slack.
- I am signed up to the Ory Security Patch Newsletter.
Ory Network Project
https://elated-johnson-lfg0voad5z.projects.oryapis.com
Describe the bug
I am able to successfully create auth2 clients using Ory REST API by setting these two lifespan fields for OAuth2 clients:
"client_credentials_grant_access_token_lifespan": "720h",
"jwt_bearer_grant_access_token_lifespan": "720h",
I am able to fetch the client using the REST endpoint, it returns these two values as:
"client_credentials_grant_access_token_lifespan": "720h0m0s",
"jwt_bearer_grant_access_token_lifespan": "720h0m0s",
But it throws exception when I try to create or list existing Oauth2 clients using Python SDK:
ValidationError: 2 validation errors for OAuth2Client
client_credentials_grant_access_token_lifespan
Value error, must validate the regular expression /^[0-9]+(ns|us|ms|s|m|h)$/ [type=value_error, input_value='720h0m0s', input_type=str]
For further information visit https://errors.pydantic.dev/2.9/v/value_error
jwt_bearer_grant_access_token_lifespan
Value error, must validate the regular expression /^[0-9]+(ns|us|ms|s|m|h)$/ [type=value_error, input_value='720h0m0s', input_type=str]
For further information visit https://errors.pydantic.dev/2.9/v/value_error
Reproducing the bug
- Create M2M Client with OAuth2Client as:
ory_client.OAuth2Client(
client_name=client_name,
grant_types=["client_credentials"],
response_types=["token"],
access_token_strategy="jwt",
skip_consent=True,
audience=["dev-audience"],
scope="read:all",
token_endpoint_auth_method="client_secret_post",
token_endpoint_auth_signing_alg="RS256",
jwt_bearer_grant_access_token_lifespan="720h",
client_credentials_grant_access_token_lifespan="720h",
)
api_response = api_instance.create_o_auth2_client(m2m_client)
Relevant log output
Exception when calling OAuth2Api->list_o_auth2_clients: 2 validation errors for OAuth2Client
client_credentials_grant_access_token_lifespan
Value error, must validate the regular expression /^[0-9]+(ns|us|ms|s|m|h)$/ [type=value_error, input_value='720h0m0s', input_type=str]
For further information visit https://errors.pydantic.dev/2.9/v/value_error
jwt_bearer_grant_access_token_lifespan
Value error, must validate the regular expression /^[0-9]+(ns|us|ms|s|m|h)$/ [type=value_error, input_value='720h0m0s', input_type=str]
Relevant configuration
No response
Version
v1.12.2
On which operating system are you observing this issue?
None
In which environment are you deploying?
None
Additional Context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Python SDK's OAuth2Client model and its validation for client_credentials_grant_access_token_lifespan and jwt_bearer_grant_access_token_lifespan. Reproduce the issue with list_o_auth2_clients and the shown 720h configuration, then verify that the REST response value 720h0m0s is accepted without validation errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100