tokenExpired method

  1. @override
Future<bool> tokenExpired()
override

Checks if the current user's authentication token is expired.

Implementation

@override
Future<bool> tokenExpired() {
  return _executeRequest(() async {
    // Make a lightweight API call to check token validity.
    // If it succeeds, the token is valid. A 401/403 error is caught by
    // _executeRequest, which then tries to re-authenticate.
    await driveApi.about.get($fields: 'user');
    return false;
  })
      .then((_) =>
          false) // If the request (and potential retry) succeeds, token is not expired.
      .catchError((_) =>
          true); // If it ultimately fails, token is considered expired.
}