Sessions
Sessions
Overview
A session in Fuse allows you to launch the importer by generating a session token. You can store metadata such as user IDs inside of a session so that when you retrieve imports from the Fuse API, you know which user in your system to associate them with.
Depending on your needs, you can choose between two options:
-
Client-Side Sessions: A simpler method that generates the session token directly in the frontend, though it exposes your API key and should only be used in trusted or testing environments.
-
Server-Side Sessions: The most secure method, as it prevents exposing sensitive data by handling session token generation on your backend.
Client-Side Session
This option is simpler but less secure, as it involves exposing your API key in the frontend. It should only be used in testing environments or trusted internal tools.
Steps:
- Implement
getSessionToken
: Directly generate the session token using the Fuse client-side token function and pass it to the importer.
Frontend Code Sample
Server-Side Sessions
This is the recommended approach for production environments, as it securely handles session token generation on your backend, keeping sensitive information safe.
Steps
- Add an API Endpoint: Create an endpoint on your server that calls the Session API to generate session tokens using an API key from your account.
- Implement
getSessionToken
: In your frontend, implementgetSessionToken
to request the session token from your server’s API endpoint and use it to launch the importer.