Summary

The currentUser() GraphQL query returns information about the current authenticated user, including their name, email address, and other account details.

Syntax

graphql
currentUser(): User!

There is no input for this query field. Specify the values you want returned, such as the username and email address. See Returned Values for more options.

Example

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 $query = "query {
	currentUser {
      id,displayName,
      username, isRoot }
}";
$query =~ s/\n/ /g;
my $json = sprintf('{"query" : "%s"}',$query);
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',
  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": "abc123",
      "displayName": "dev",
      "username": "dev",
      "isRoot": true
    }
  }
}

The example above requests commonly used identity fields: username, email address, full name, and role.

Returned Values

Returns a non-nullable User object with extensive information about the user account. Fields include standard details (for example, name and email address), user permissions and access, group membership, and assets the user can access. The available fields are listed here:

Table: User Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
allowedOrganizationActionsOrganizationActionyes Long-Term Returns the actions the user is allowed to perform in the organization.
allowedSystemActionsSystemActionyes Long-Term Returns the actions the user is allowed to perform in the system.
assetIdString,yes   Id of the asset
assetTypeAssetPermissionsAssetType,yes   The type of the asset.
assetTypesAssetPermissionsAssetType],yes   List of asset types
companyString  Long-Term  
countryCodeString  Long-Term  
createdAtDateTimeyes Long-Term  
displayNameStringyes Long-Term fullName if present, otherwise username.
emailString  Long-Term  
externalUsernameString  Long-Term Readable username for when user stems from Falcon
firstNameString  Long-Term  
fullNameString  Long-Term  
groupSearchDomainRolesGroupSearchDomainRoleyes Long-Term  
groupsGroupyes Long-Term The groups the user is a member of.
idStringyes Long-Term  
isOrgRootBooleanyes Long-Term  
isRootBooleanyes Long-Term  
lastNameString  Long-Term  
limitInt,    The amount of results to return.
orderByOrderBy,    Choose the order in which the results are returned.
permissionsAssetAction]):AssetPermissionSearchResultSetyes Short-Term Include Read, Update and/or Delete permission assignments. The filter will accept all assets if the argument Null or the empty list.
phoneNumberString  Long-Term  
pictureString  Long-Term  
searchDomainIdString):[AssetActionsBySourceyes Short-Term Search domain id
searchDomainIdsString],yes   List of search domain id's to search within. Null or empty list is interpreted as all search domains
searchDomainRoles(searchDomainId: String)SearchDomainRoleyes Long-Term  
searchDomainRolesByName(searchDomainName: String!)SearchDomainRole   deprecated in 1.195 
searchDomainRolesBySearchDomainName(searchDomainName: String!)SearchDomainRoleyes Long-Term  
searchFilterString,    Filter results based on this string
skipInt,searchInRoles:Boolean):GroupResultSetTypeyes Short-Term The number of results to skip or the offset to use. For instance if implementing pagination, set skip = limit * (page - 1)
sortBySortBy,    The sort by options for assets. Asset name is default
stateCodeString  Long-Term  
usernameStringyes Long-Term  
viewNameString):[UserPermissionsyes Long-Term Exact name of the repo to find permissions for.