initialise static method
void
initialise({})
Initialises the SuperTokens SDK
Uses the refreshTokenEndpoint
to make a call to refresh the session when needed,
the sessionExpiryStatusCode
is used to determine unauthorised access API errors.
refreshAPICustomHeaders
are always sent when calling the refresh endpoint.
Throws a FormatException if an invalid URL is provided for refreshTokenEndpoint
.
Implementation
static void initialise({
required String refreshTokenEndpoint,
int sessionExpiryStatusCode = 401,
Map<String, String> refreshAPICustomHeaders = const {},
}) {
if (SuperTokens.isInitCalled) {
return;
}
SuperTokens.refreshAPICustomHeaders = refreshAPICustomHeaders;
SuperTokens.sessionExpiryStatusCode = sessionExpiryStatusCode;
SuperTokens.refreshTokenEndpoint =
_transformRefreshTokenEndpoint(refreshTokenEndpoint);
SuperTokens.apiDomain = SuperTokensUtils.getApiDomain(refreshTokenEndpoint);
SuperTokens.isInitCalled = true;
}