You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today I updated my ory_hydra_client python library and ory/hydra backend to version 2.0.1. After that, when trying to get a token using the OAuth2Api.oauth2_token_exchange(grant_type="client_credentials"), I am getting an error saying "Invalid type for variable 'scope'. Required value type is int and passed type was str at ['received_data']['scope']".
where the client expects to receive an integer for the scope field from the hydra server but instead it receives a string (as it should).
Performing the same flow with the same credentials through an HTTP call (using postman) works fine. The previous version of the library worked also fine for o_auth2_token() function. This looks like a typo to me.
I can provide my code but I don't think this is an issue caused by my config.
Reproducing the bug
Steps to reproduce:
Have hydra server v2.0.1 running somewhere.
Install ory_hydra_client v2.0.1 python library and setup the endpoints to hydra server.
Create an oauth2 client (through the python library or HTTP request to hydra server).
Try to perform the oauth 2 token flow using the OAuth2Api.oauth2_token_exchange() function of the ory_hydra_client library.
You should get the same error as me.
Relevant log output
Traceback (most recent call last):
File "/code/./app/routers/public.py", line 65, in request_access_token
result = client.oauth2_token_exchange(grant_type="client_credentials").to_dict()
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/api/o_auth2_api.py", line 3057, in oauth2_token_exchange
return self.oauth2_token_exchange_endpoint.call_with_http_info(**kwargs)
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/api_client.py", line 880, in call_with_http_info
return self.api_client.call_api(
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/api_client.py", line 422, in call_api
return self.__call_api(resource_path, method,
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/api_client.py", line 227, in __call_api
return_data = self.deserialize(
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/api_client.py", line 333, in deserialize
deserialized_data = validate_and_convert_types(
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model_utils.py", line 1583, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model_utils.py", line 1472, in attempt_convert_item
raise conversion_exc
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model_utils.py", line 1463, in attempt_convert_item
return deserialize_model(input_value, valid_class,
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model_utils.py", line 1377, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model_utils.py", line 49, in wrapped_init
return fn(_self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model_utils.py", line 372, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model_utils.py", line 49, in wrapped_init
return fn(_self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model/o_auth2_token_exchange.py", line 192, in _from_openapi_data
setattr(self, var_name, var_value)
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model_utils.py", line 190, in __setattr__
self[attr] = value
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model_utils.py", line 511, in __setitem__
self.set_attribute(name, value)
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model_utils.py", line 162, in set_attribute
value = validate_and_convert_types(
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model_utils.py", line 1583, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/usr/local/lib/python3.10/site-packages/ory_hydra_client/model_utils.py", line 1458, in attempt_convert_item
raise get_type_error(input_value, path_to_item, valid_classes,
ory_hydra_client.exceptions.ApiTypeError: Invalid typefor variable 'scope'. Required value type is int and passed type was str at ['received_data']['scope']
Relevant configuration
hydra:
image: oryd/hydra:v2.0.1container_name: hydraports:
- "4444:4444"# Public port
- "4445:4445"# Admin port
- "5555:5555"# Port for hydra token usercommand: serve -c /etc/config/hydra/hydra.yml all --devvolumes:
- type: bindsource: ./config/hydratarget: /etc/config/hydraenvironment:
- DSN=mysql://root:secret@tcp(mysql-admin:3306)/mysql?max_conns=20&max_idle_conns=4
- HYDRA_URL=http://localhost:4445restart: unless-stoppeddepends_on:
- hydra-migratehydra-migrate:
container_name: hydra-migrateimage: oryd/hydra:v2.0.1environment:
- DSN=mysql://root:secret@tcp(mysql-admin:3306)/mysql?max_conns=20&max_idle_conns=4command: migrate -c /etc/config/hydra/hydra.yml sql -e --yesvolumes:
- type: bindsource: ./config/hydratarget: /etc/config/hydrarestart: on-failuredepends_on:
- mysql-admin
Version
2.0.1
On which operating system are you observing this issue?
Linux
In which environment are you deploying?
Docker Compose
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Hi @aeneasr, as you can see I have now created PR #223 with the necessary change to fix this issue. I have tested it locally with my project and I can confirm it works as expected. 🙂
Preflight checklist
Describe the bug
Hello there.
Today I updated my ory_hydra_client python library and ory/hydra backend to version 2.0.1. After that, when trying to get a token using the OAuth2Api.oauth2_token_exchange(grant_type="client_credentials"), I am getting an error saying
"Invalid type for variable 'scope'. Required value type is int and passed type was str at ['received_data']['scope']"
.I looked into it and the issue seems to be here
sdk/clients/hydra/python/ory_hydra_client/model/o_auth2_token_exchange.py
Line 89 in 847fa44
where the client expects to receive an integer for the scope field from the hydra server but instead it receives a string (as it should).
Performing the same flow with the same credentials through an HTTP call (using postman) works fine. The previous version of the library worked also fine for o_auth2_token() function. This looks like a typo to me.
I can provide my code but I don't think this is an issue caused by my config.
Reproducing the bug
Steps to reproduce:
Relevant log output
Relevant configuration
Version
2.0.1
On which operating system are you observing this issue?
Linux
In which environment are you deploying?
Docker Compose
Additional Context
No response
The text was updated successfully, but these errors were encountered: