Token

A token is a type of authentication secret used to provide identity-based access to a Fauna database.

You typically create and use tokens as part of a Fauna-based end-user authentication system.

Token collection

Fauna stores tokens as documents in the Token system collection.

Token documents have the following FQL structure:

{
  id: "401671202234433613",
  coll: Token,
  ts: Time("2099-06-25T13:32:39.240Z"),
  ttl: Time("2099-06-27T13:32:39.240Z"),
  document: Customer("401670531121676365"),
  secret: "fn..."
}
Field name Value type Description

id

ID

A unique identifier for a token. Fauna assigns this value at creation.

coll

Token

ts

Creation timestamp, with microsecond resolution and time zone.

ttl

Timestamp indicating a document lifespan. When the ttl is reached, Fauna removes it. If ttl isn’t provided, the value is null and the document persists indefinitely or until deleted.

document

Ref

The identity document associated with the token.

secret

Randomly generated cryptographic hash. Equivalent to a password.

data

User-defined metadata for the token.

Static methods

You can use the following static methods to manage the Token collection in FQL.

Method Description

Get the Set of all Token objects.

Get a Token by Document.

Get a Token by ID.

Create a Token.

Get the first token matching a predicate function.

Get the name of the Token collection as a string.

Get tokens matching a predicate function.

Instance methods

You can use the following instance methods to manage specific Token documents in FQL.

Method Description

Delete a Token.

Verify a Token.

Replace a Token.

Update a Token.

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!