Returns information about a user. If no argument is given, this function will return information about the currently logged in user.
This function requires GRANT
privileges on the @thingsdb
scope when a username
other then the logged in user is given as argument. For the currently logged in user, QUERY
privileges on the @thingsdb
scope are sufficient.
This function is accessible from any scope when invoked without arguments (since version 1.6.6).
This function does not generate a change.
user_info([username])
Argument | Type | Description |
---|---|---|
username | str (optional) | Name of the user |
Returns mpdata about the user.
This code returns info for the authenticated user:
// Without a `username`, info about the currently logged in user is returned
user_info();
Example output in JSON format:
{
"access": [
{
"privileges": "FULL",
"scope": "@node"
},
{
"privileges": "FULL",
"scope": "@thingsdb"
},
{
"privileges": "FULL",
"scope": "@collection:stuff"
}
],
"created_at": 1573981254,
"has_password": true,
"name": "admin",
"tokens": [
{
"created_on": "2019-11-17T09:25:36Z",
"expiration_time": "2020-11-17T09:25:36Z",
"key": "QpVmHOsfQaKKpjpOkW0SUt",
"status": "OK"
}
],
"user_id": 1,
"whitelists": {}
}