SurrealDB Docs Logo

Enter a search query

.Authenticate()

Authenticates the current connection with a JWT token.

Method Syntax
db.Authenticate(token)

Arguments

ArgumentsDescription
token required

The JWT authentication token.

Example usage

db.Authenticate("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJTdXJyZWFsREIiLCJpYXQiOjE1MTYyMzkwMjIsIm5iZiI6MTUxNjIzOTAyMiwiZXhwIjoxODM2NDM5MDIyLCJOUyI6InRlc3QiLCJEQiI6InRlc3QiLCJTQyI6InVzZXIiLCJJRCI6InVzZXI6dG9iaWUifQ.N22Gp9ze0rdR06McGj1G-h2vu6a6n9IVqUbMFJlOxxA");
// Check token validity. This is not necessary if you called `SignIn` before. This authenticates the `db` instance too if sign in was // not previously called if err := db.Authenticate(token); err != nil { panic(err) }

You can invalidate the authentication for the current connection using the Invalidate() method.

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install