Check out v4 of the Fauna CLI

v4 of the Fauna CLI is now in beta.

The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start.

Token

Learn: Tokens

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 Read-only Required Description

id

ID

ID for the Token document. The ID is a string-encoded, 64-bit unsigned integer in the 253-1 range. The ID is unique within the collection.

IDs are assigned at document creation. To create a token with a user-provided id using Token.create(), you must use a secret with the create_with_id privilege for the Token collection. If not provided, Fauna generates the id.

coll

true

Collection name: Token.

ts

true

Last time the document was created or updated.

ttl

Time-to-live (TTL) for the document. Only present if set. If not present or set to null, the document persists indefinitely.

document

Ref

true

The identity document associated with the token.

secret

Randomly generated cryptographic hash. Equivalent to a password.

data

Arbitrary user-defined metadata for the document.

Static methods

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

Method Description

Get a Set of all tokens.

Get a token by its identity document.

Get a token by its document id.

Create a token without a credential or related password.

Get the first token that matches a provided predicate.

Get "Token" as a String.

Get a Set of tokens that match a provided predicate.

Instance methods

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

Method Description

Delete a token.

Test if a token exists.

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!