revokeAccessToken method

Future<void> revokeAccessToken()

An access_token can be revoked when a user signs out of their Trakt account in your app.

This is not required, but might improve the user experience so the user doesn't have an unused app connection hanging around.

Implementation

Future<void> revokeAccessToken() async {
  final url = Uri.https(_manager._baseURL, "oauth/token");
  final body = {
    "token": _manager._accessToken,
    "client_id": _manager._clientId!,
    "client_secret": _manager._clientSecret!,
  };
  final response = await _manager.client.post(url, headers: {"Content-Type": "application/json"}, body: body);

  if (![200, 201, 204].contains(response.statusCode)) {
    throw TraktManagerAPIError(response.statusCode, response.reasonPhrase, response);
  }

  _manager._accessToken = null;
  _manager._refreshToken = null;

  return;
}