Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Labels
bugThis points to a verified bug in the code
@ayharano

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis points to a verified bug in the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /