getNewAccessToken method

Future<String?> getNewAccessToken(
  1. String accessToken
)

Attempts to refresh the access token using the provided accessToken. This method calls an API to request a new token and returns it via a Completer.

Implementation

Future<String?> getNewAccessToken(String accessToken) async {
  Completer<String?> accessTokenCompleter = Completer();
  LocalityAPI.call("api/refresh_token", {'access_token': accessToken},
      (success, answerData) {
    if (!success) accessTokenCompleter.complete();
    if (success) accessTokenCompleter.complete(answerData['access_token']);
  });
  return accessTokenCompleter.future;
}