.SignIn()
Signs in to a root, namespace, database or scope user.
Method Syntaxawait db.SignIn(credentials)
Arguments | Description | ||
---|---|---|---|
credentials required | Variables used in a signin query. | ||
cancellationToken optional | The cancellationToken enables graceful cancellation of asynchronous operations. |
// Sign in as root user await db.SignIn(new RootAuth { Username = "root", Password = "root" });
// Sign in using namespace auth await db.SignIn( new NamespaceAuth { Namespace = "test", Username = "johndoe", Password = "password123" } );
// Sign in using database auth await db.SignIn( new DatabaseAuth { Namespace = "test", Database = "test", Username = "johndoe", Password = "password123" } );
// Sign in with Record Access var authParams = new AuthParams { Namespace = "test", Database = "test", Access = "user", Email = "info@surrealdb.com", Password = "123456" }; Jwt jwt = await db.SignIn(authParams); public class AuthParams : ScopeAuth { public string? Username { get; set; } public string? Email { get; set; } public string? Password { get; set; } }
// Sign in as a scoped user var authParams = new AuthParams { Namespace = "test", Database = "test", Scope = "user", Email = "info@surrealdb.com", Password = "123456" }; Jwt jwt = await db.SignIn(authParams); public class AuthParams : ScopeAuth { public string? Username { get; set; } public string? Email { get; set; } public string? Password { get; set; } }
You can invalidate the authentication for the current connection using the Invalidate()
method.