Skip to content

AuthorizationEvent

class 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((AuthorizationEvent event) {
  if (event.success) {
    print('[onAuthorization] Token refreshed: ${event.response}');
    // Update your app's stored token.
    final token = event.response.access_token;
  } else {
    print('[onAuthorization] Refresh failed: ${event.error}');
  }
});

Members

error

String? error

Error message when success is false; null otherwise.

response

Map? response

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

status

int status

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

success

bool success

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