Created
October 24, 2021 10:24
-
-
Save vaygeth89/ef80eccfb448758a8b09e3fb55158633 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Future<bool> verifyToken( | |
{required String accessToken, String routePath = "verify-token"}) async { | |
try { | |
var result = await super._dio.get(routePath, | |
queryParameters: {"accessToken": accessToken}).timeout(super.timeout); | |
if (result.statusCode == 200) { | |
return true; | |
} | |
throw DioError(requestOptions: result.requestOptions); | |
} on DioError catch (error) { | |
if (error.response!.statusCode! >= 400) { | |
throw AccessTokenException(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