The currentUser() GraphQL query returns information about the current authenticated user.

For more information on user authorization, see the Managing Users & Permissions documentation page.

Syntax

Below is the syntax for the currentUser() query field:

graphql
currentUser: User!

In addition to the datatype User you'll have to specify which values you want returned — at least one value, id. Below is an example with a few values requested:

Raw
graphql
query {
	currentUser {
    id,
    displayName,
    username,
    isRoot
	}
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "query {
	currentUser {
    id,
    displayName,
    username,
    isRoot
	}
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "query {
	currentUser {
    id,
    displayName,
    username,
    isRoot
	}
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "query { ^
	currentUser { ^
    id, ^
    displayName, ^
    username, ^
    isRoot ^
	} ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query {
	currentUser {
    id,
    displayName,
    username,
    isRoot
	}
}"
}'
"$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $json = '{"query" : "query {
	currentUser {
    id,
    displayName,
    username,
    isRoot
	}
}"
}';
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "query {
	currentUser {
    id,
    displayName,
    username,
    isRoot
	}
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "query {
	currentUser {
    id,
    displayName,
    username,
    isRoot
	}
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL/graphql',
  path: '/graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "currentUser": {
      "id": "zLkpYGQaPaEBxxYwfWYj3fqG",
      "displayName": "dev",
      "username": "dev",
      "isRoot": true
    }
  }
}

Notice that the example above requests four values be returned. They're separated by commas.

Given Datatypes

The given datatype User has its own parameters. Below is a list of them, along with their datatypes and a description of each:

Table: User

ParameterTypeRequired[a]DefaultDescription
idstringyes The identifier or token for the user.
displayNamestringyes The value of the fullName if used, otherwise the username.
usernamestringyes The user name for the account.
isRootbooleanyes Whether the user account is granted root access.
isOrgRootbooleanyes Whether the organization is granted root access.
fullNamestring  The user's full name (e.g., Bob Smith). Don't use if using other name parameters.
firstNamestring  The user's actual first name (e.g., Bob). Don't use with fullName.
lastNamestring  The user's actual last name or family name (e.g., Smith). Don't use with fullName.
phoneNumberstring  The telephone number for LogScale to use for telephone text messages.
emailstring  The user account's email address for communications from LogScale.
picturestring  File name of an image file for the account.
createdAtdatetimeyes The data and time the account was created.
countryCodestring  The two-letter ISO 3166-1 Alpha-2 code for the country of residence (e.g., us).
stateCodestring  The two-letter, ISO 3166-2 country sub-division code for the state of residence (e.g., ny).
companystring  The name of the company for the user account.
userOrGroupSearchDomainRolessearch: string, skip: Int = 0, limit: Int = 50): UserOrGroupSearchDomainRoleResultSet!yes The number of results to skip or the offset to use. For instance, if implementing pagination, set skip = limit * (page - 1). See UserOrGroupSearchDomainRoleResultSet Table.
groupSearchDomainRolesGroupSearchDomainRoleyes The group search domain roles for the user (see GroupSearchDomainRole Table).
searchDomainRoles[SearchDomainRole]  The search domain roles assigned to the user (see SearchDomainRole Table).
searchDomainRolesByNamestringyes The search domain roles for the user, by name.
group[Group]yes The groups of which the user is a member (see Group Table).
permissionstypeyes Permissions of the user.
permissionsPagetypeyes PREVIEW: A page of user permissions.
allowedSystemActions[SystemAction]yes Returns the actions the user is allowed to perform in the system. See SystemAction Table.
allowedOrganizationActions[OrganizationAction]yes Returns the actions the user is allowed to perform in the organization (see OrganizationAction Table).

[a] Some arguments may be required, as indicated in this column. For some fields, this column indicates that a result will always be returned for it.