Get auth header after create-database

After creating a database in fauna shell with the create-database command, we know how to get an admin key to load a schema from the command line, but then, in order to populate data in the newly created documents with graphql mutations from the command line using curl, we need the auth header?

We can get the auth header from Fauna dashboard, no problem, but is there a way to get the auth header from the shell?

Hi @Michael_Godeck,

When you login using the Fauna shell, you can use the Login() function to handle your authentication. When the user is successfully authenticated the shell will return the token that can be used in the auth header in subsequent connections.

For example, using this sample from our docs:

  Match(Index("users_by_email"), "alice@site.example"),
  { password: "secret password" },

The result in this case would be something like:

{ ref: Ref(Tokens(), "251407817091580416"),
  ts: 1576020028130000,
  instance: Ref(Collection("users"), "251407645221585408"),
  secret: 'fnEDfS4T34ACAAN9IwrU8aQA5SxTgyqYaUfiAqLqzQjQH9Qcr94' }

Future connections using curl would pass the value of that secret as the user portion of the auth token:

curl \
  -u fnEDfS4T34ACAAN9IwrU8aQA5SxTgyqYaUfiAqLqzQjQH9Qcr94:

Please let us know if this answers your question.