Last updated

getSessionToken()

Gets the current session token. Throws an error if the session is not available.

Signature

const token = window.FairShareSDK.getSessionToken();

Returns

string — Session token identifier.

Example

try {
  const sessionToken = window.FairShareSDK.getSessionToken();
  console.log('Session:', sessionToken);
} catch (error) {
  console.error('Session not available:', error.message);
}

Error Handling

This method throws if the session token is not available. Common reasons:

  1. initializeFairshare() hasn't been called yet
  2. Session initialization is still in progress
  3. Session creation failed (check network connectivity)
  4. Invalid fluidShop identifier