Table of Contents
Make sure you you followed the setting up guide for user authentication beforehand!
Usage
To sign a user in, use the signIn
method. You'll need to supply an email, password, baseId and rememberMe.
Parameters
email string | The email of the user you want to sign in. |
password string | The password of the user you want to sign in. |
baseId string | The baseId of the base where you want to add the user to. |
rememberMe string | null | You can enter either session local or none. session saves the login for the current browser session. The user will be signed out on closing the tab or browser. local saves the login in local storage. Making it persistent through browser closes. none doesn't save the login. The login will be forgotten after a page refresh. |
Code sample
signIn
returns a Promise which resolves to an authenticated Flairtable instance. With this instance you can
create, update and delete, but more on that later.
const authenticatedFlairtable = await Flairtable({apiKey: 'YOUR_API_KEY',}).signIn('YOUR_BASE_ID', 'EMAIL', 'PASSWORD', 'session');const base = authenticatedFlairtable.base('YOUR_BASE_ID');
If you don't like async/await, you can also use thenables:
const authenticatedFlairtable = await Flairtable({apiKey: 'YOUR_API_KEY',}).signIn('YOUR_BASE_ID', 'EMAIL', 'PASSWORD').then((authenticatedFlairtable) => {const base = authenticatedFlairtable.base('YOUR_BASE_ID');});
If you supplied a rememberMe
parameter you can instantiate an instance of Flairtable
anywhere, and it will be authenticated.
If you want to react to changes in auth state, check out the onAuthChange guide.