• Start

Languages

/

Swift

/

Methods

signin

The signin() method for the SurrealDB Swift SDK signs in to a specific authentication level.

Signs this connection in to a specific authentication level and returns the issued tokens.

Method Syntax

let tokens = try await client.signin(credentials)
ArgumentsDescription
credentials The credentials to authenticate with: one of .root, .namespace, .database, .accessVariables or .accessBearer.
// Root user
let tokens = try await client.signin(.root(username: "root",
password: "root"))

// Database user
let tokens = try await client.signin(.database(
namespace: "myapp",
database: "mydb",
username: "db_user",
password: "secret"
))

// Record access with variables
let tokens = try await client.signin(.accessVariables(
namespace: "myapp",
database: "mydb",
access: "account",
variables: ["email": .string("user@example.com"),
"pass": .string("secret")]
))

See Authentication for every supported credentials variant.

Was this page helpful?