Class SupabaseSession

java.lang.Object
com.codename1.cloud.supabase.SupabaseSession

public final class SupabaseSession extends Object
A signed-in Supabase user session: the access token, the refresh token and when the access token expires.
  • Constructor Details

    • SupabaseSession

      public SupabaseSession(String accessToken, String refreshToken, long expiresAt, String userId, String email)

      Creates a session.

      Parameters
      • accessToken: the JWT sent with requests

      • refreshToken: the token that renews the session

      • expiresAt: when the access token expires, in seconds since the epoch

      • userId: the user ID

      • email: the user's email, may be null

  • Method Details

    • fromJson

      public static SupabaseSession fromJson(Map<String,Object> json)

      Reads a session from a GoTrue token response.

      Parameters
      • json: the parsed response
      Returns

      the session, or null when the response holds no access token

    • getAccessToken

      public String getAccessToken()

      The access token (a JWT).

      Returns

      the token

    • getRefreshToken

      public String getRefreshToken()

      The refresh token.

      Returns

      the token, may be null

    • getExpiresAt

      public long getExpiresAt()

      When the access token expires.

      Returns

      seconds since the epoch

    • getUserId

      public String getUserId()

      The user ID.

      Returns

      the ID, may be null

    • getEmail

      public String getEmail()

      The user's email.

      Returns

      the email, may be null

    • isExpired

      public boolean isExpired()

      True when the access token expires within the next minute.

      Returns

      whether the session needs a refresh