Last updated

User

The User section provides tools for managing user authentication state. These functions allow you to check if a user is logged in and set authentication after completing OAuth flows.


What's Included

FunctionDescription
getAuthenticatedUserGet the currently authenticated user
setAuthenticationSet authentication with JWT token

Benefits

  • Authentication State — Check if a user is currently logged in
  • User Information — Access user details like name, email, and avatar
  • OAuth Integration — Set authentication after completing OAuth flows
  • Session Management — Programmatically manage user sessions

Quick Example

// Get authenticated user
const user = window.FairShareSDK.getAuthenticatedUser();

if (user) {
  console.log('Logged in as:', user.name);
} else {
  console.log('Not authenticated');
}

// Set authentication with JWT token
window.FairShareSDK.setAuthentication("your-jwt-token");