Skip to content

Instantly share code, notes, and snippets.

@vaygeth89
Created October 24, 2021 10:35
Show Gist options
  • Save vaygeth89/2cec18d8355b4763d81475d01af4a996 to your computer and use it in GitHub Desktop.
Save vaygeth89/2cec18d8355b4763d81475d01af4a996 to your computer and use it in GitHub Desktop.
@override
Future<AuthenticationData> renewAccessToken(
{required RenewAccessToken renewAccessToken,
String routePath = "renew-token"}) async {
try {
var result = await super
._dio
.post(routePath, data: renewAccessToken.toJson())
.timeout(super.timeout);
if (result.statusCode == 200) {
return AuthenticationData.fromJson(result.data);
}
throw DioError(requestOptions: result.requestOptions);
} on DioError catch (error) {
if (error.response!.statusCode! >= 400) {
throw RefreshTokenException(message: "Token invalid or expired");
}
var businessError = BusinessError.fromJson(error.response?.data);
throw BusinessException(businessError,
statusCode: error.response?.statusCode);
} catch (error) {
throw Error();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment