FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date.

Fauna accounts created after August 21, 2024 must use FQL v10. These accounts will not be able to run FQL v4 queries or access the v4 Dashboard.

For more details, see the v4 EOL announcement and migration guide. Contact support@fauna.com with any questions.

Identity

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

Identity()
identity()
Identity()
Identity()
Identity()
Identity()

Description

This function is deprecated as of API version 4. Use the CurrentIdentity function instead.

See the Deprecations page for more details.

The Identity function returns the Reference of the identity document involved in the current query, if there is one. You can use the Reference to fetch the identity document and inspect its contents.

Authorization for every Fauna query involves a secret, which was created by a key, token, or is embedded in a JSON Web Token (JWT).

The secrets for keys provide anonymous, role-based access to a Fauna database, so no identity document is available. If you call Identity when using a key’s secret, an error occurs.

When authentication is performed by an identity provider, Identity returns the contents of the associated JWT’s sub field.

Parameters

None.

Returns

A Reference to the identity document authorized to run the current query, or an error when using anonymous authorization.

Examples

client.query(
  q.Identity()
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
Ref(Collection("users"), "1")
result = client.query(
  q.identity()
)
print(result)
Ref(id=1, collection=Ref(id=users, collection=Ref(id=collections)))
result, err := client.Query(
	f.Identity())

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
{1 0xc000170150 0xc000170150 <nil>}
try
{
    Value result = await client.Query(
        Identity()
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
RefV(id = "1", collection = RefV(id = "users", collection = RefV(id = "collections")))
System.out.println(
    client.query(
        Identity()
    ).get());
ref(id = "1", collection = ref(id = "users", collection = ref(id = "collections")))
Identity()
Ref(Collection("users"), "1")
Query metrics:
  •    bytesIn:  17

  •   bytesOut: 112

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:  96

  • writeBytes:   0

  •  queryTime: 6ms

  •    retries:   0

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!