Skip to content

AuthorizationEvent

export interface AuthorizationEvent {

Authorization token refresh result delivered to BackgroundGeolocation.onAuthorization.

The SDK fires this event after each token refresh attempt triggered by AuthorizationConfig.refreshUrl. Use it to update your app's local credential store, handle refresh failures, or react to expired sessions.

BackgroundGeolocation.onAuthorization((event) => {
  if (event.success) {
    console.log("[onAuthorization] Token refreshed:", event.response);
    // Update your app's stored token.
    const token = event.response.access_token;
  } else {
    console.warn("[onAuthorization] Refresh failed:", event.error);
  }
});

Members

error

error: string;

Error message when success is false; null otherwise.

response

response: any;

Decoded JSON body returned by the refresh server when success is true; null otherwise.

status

status: number;

HTTP status code returned by AuthorizationConfig.refreshUrl, or 0 if the request failed before reaching the server.

success

success: boolean;

true when the token refresh request returned a 2xx status code.