SDK
Authentication

Authentication

To authenticate, you must provide an Access Token Service. Currently, there are two Access Token Service available PersonalAccessTokenService and ApplicationAccessTokenService, but we’re working on adding more services.

Available Authenticaition options

Auth methodWeb EnvironmentNode Environment
PersonalAccessTokenService
ApplicationAccessTokenService

Updating AccessTokenService

If you need to access multiple projects or switch between them, you will need to create a new instance of the SDK with the desired projectID

import { FleekSdk, PersonalAccessTokenService } from '@fleekxyz/sdk';
 
const newAccessTokenService = new PersonalAccessTokenService({
	personalAccessToken: '<your-personal-access-token>',
	projectId: '<your-project-id>',
})
 
const fleekSdk = new FleekSdk({ accessTokenService: newAccessTokenService });

Personal Access Token Service

⚠️

The personal access token (PAT) is ment to be used in Backend Node.js environment and should be kept private, you should use an environment variable to store it.

Parameters

parametersdescription
personalAccessTokenPrivate PAT, generated from the CLI.
projectId (Optional)Project Id is required for specific services.

This method of authentication relies on a personalAccessToken which can be obtained from the Fleek CLI:

fleek pat create

Example

import { FleekSdk, PersonalAccessTokenService } from '@fleekxyz/sdk';
 
const patService = new PersonalAccessTokenService({
    personalAccessToken: '<your-pat>',
    projectId: '<your-project-id>' // Optional
})
 
const fleekSdk = new FleekSdk({ accessTokenService: patService })
Last updated on May 30, 2023