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

Both remove_permissions and add_permissions from auth0.management.users.Users have wrong permission representation #622

Open
5 tasks done
ayharano opened this issue Jun 6, 2024 · 0 comments
Labels
bug This points to a verified bug in the code

Comments

@ayharano
Copy link

ayharano commented Jun 6, 2024

Checklist

  • I have looked into the Readme and Examples, and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

Checking the API docs from

  • Auth0 Management API v2 > Users > Assign permissions to a user [link], and
  • Auth0 Management API v2 > Users > Remove permissions from a user [link]

we can verify that a permission is represented by a dict with two values:

    {
      "resource_server_identifier": "string",
      "permission_name": "string"
    }

while the auth0-python implementation expects str (referring to 4.7.1 code snippet: [link]

(method reference: auth0.management.users.Users.remove_permissions and auth0.management.users.Users.add_permissions)

Reproduction

Using a CPython 3.12.3 venv with auth0-python 4.7.1

>>> from auth0.management.auth0 import Auth0
>>> auth0_ = Auth0(
...     domain="MY_DOMAIN",
...     token="MY_TOKEN",
... )
>>> auth0_.users.add_permissions(id="USER_ID", permissions=["EXISTING_PERMISSION_NAME"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/project/.venv/lib/python3.12/site-packages/auth0/management/users.py", line 309, in add_permissions
    return self.client.post(url, data=body)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/auth0/rest.py", line 207, in post
    return self._request("POST", url, json=data, headers=request_headers)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/auth0/rest.py", line 187, in _request
    return self._process_response(response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/auth0/rest.py", line 258, in _process_response
    return self._parse(response).content()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/auth0/rest.py", line 294, in content
    raise Auth0Error(
auth0.exceptions.Auth0Error: 400: Payload validation error: 'Expected type object but found type string' on property permissions[0].
>>>

Additional context

No response

auth0-python version

4.7.1

Python version

3.12.3

@ayharano ayharano added the bug This points to a verified bug in the code label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code
Projects
None yet
Development

No branches or pull requests

1 participant