Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth2 Clients: Error in Fetching Clients due to Lifespan fields throwing validation errors #376

Open
4 of 5 tasks
anichrelay-bloom opened this issue Sep 9, 2024 · 4 comments
Labels
bug Something is not working.

Comments

@anichrelay-bloom
Copy link

anichrelay-bloom commented Sep 9, 2024

Preflight checklist

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

  1. 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

@anichrelay-bloom anichrelay-bloom added the bug Something is not working. label Sep 9, 2024
@aeneasr
Copy link
Member

aeneasr commented Sep 14, 2024

Thank you for the report, can you please try with a newer version of the SDK?

@anichrelay-bloom
Copy link
Author

Thank you for the report, can you please try with a newer version of the SDK?

I believe I am seeing this error on the latest version, I did not specify any version while doing pip install

@aeneasr
Copy link
Member

aeneasr commented Sep 16, 2024

In your issue it says:

Version

v0.0.54

@anichrelay-bloom
Copy link
Author

I mentioned the latest release tag I saw for ory/sdk on github. Updated the issue with ory-client version I am using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

2 participants