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

User.get_user doesn't work #39

Open
detrout opened this issue May 15, 2019 · 2 comments
Open

User.get_user doesn't work #39

detrout opened this issue May 15, 2019 · 2 comments

Comments

@detrout
Copy link

detrout commented May 15, 2019

Hi,

I needed to look up my user id because I'm using LDAP and my user id is a UUID generated by nextcloud and not my user name.

Unfortunately User.get_user() doesn't work because the OCS end point for information about a user is:
/ocs/v1.php/cloud/user

But the User class's end point is:
/ocs/v1.php/cloud/users
(with an S)

I tested on nextcloud 13.0.4 and 15.0.7

I'd guess the solution is to rename the current class to Users and add a new class User that points to the '/ocs/v1.php/cloud/user endpoint and move the get_user function to it.

Also it'd be super convenient if commands that took a uid could default to the logged in user.

@matejak
Copy link

matejak commented May 16, 2019

Could you please clarify what you mean by user endpoint? The API documentation mentions only users.
If you have hit a bug that you can reproduce, could you please open a pull request with a failing test?

@detrout
Copy link
Author

detrout commented May 16, 2019

The nextcloud API documentation leaves quite a bit to be desired.

I found the url by looking in my apache logs and watching what the desktop client was doing.

I was trying to get my user id as on systems using ldap the user id is a random uuid and not the username one uses to login with. I tried to do server.get_user() (with the username or with the string '') to get information about the currently logged in user but both versions failed

>>> server = nextcloud.NextCloud(endpoint=endpoint, user=user, password=password, json_output=True)
>>> u = server.get_user(user)
>>> u
<OCSResponse: Status: Failed>
>>> u.data
[]
>>> u = server.get_user('')
>>> u
<OCSResponse: Status: Failed>
>>> u = server.get_current_user()
>>> u.data
{'id': 'daf814f2-6a8a-44cf-ae86-64c2cef21a93',
 'quota': {'free': 7960640296,
  'used': 2776777944,
  'total': 10737418240,
  'relative': 25.86,
  'quota': 10737418240},
 'email': '',
 'phone': '',
 'address': '',
 'website': '',
 'twitter': '',
 'groups': [],
 'language': 'en',
 'display-name': 'Diane Trout'}
}}}

get_current_user was a function I added that ends up calling the /ocs/v1.php/cloud/user endpoint

I did find the php routes file that defines it.

['root' => '/cloud', 'name' => 'Users#getUser', 'url' => '/users/{userId}', 'verb' => 'GET'],
['root' => '/cloud', 'name' => 'Users#getCurrentUser', 'url' => '/user', 'verb' => 'GET'],

https://github.com/nextcloud/server/blob/4bf641ff5d0d31037b84520d1c1b3514c1deb2e3/apps/provisioning_api/appinfo/routes.php#L50

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

No branches or pull requests

2 participants