Open detrout opened 5 years ago
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?
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'],
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.