Commit 63e6e66f authored by Aziz Berkay Yesilyurt's avatar Aziz Berkay Yesilyurt
Browse files

refresh token if expired

parent e88ab6d8
Showing with 13 additions and 1 deletion
+13 -1
......@@ -227,6 +227,11 @@ class PodService extends ApiService<PodAPI> {
return resMap['accessToken'];
}
Future<String?> oauth2GetAccessToken({required String platform}) async {
dynamic resMap = await api.oauth2GetAccessToken(platform);
return resMap['accessToken'];
}
Future<AuthUrl> oauth2url(
{required String redirectUrl,
required List<String> scopes,
......
......@@ -640,7 +640,14 @@ class AppProvider with ChangeNotifier {
if (response.statusCode == 200) {
return true;
} else {
// Token is invalid
// Token is invalid. maybe expiredfirst try to refresh
try {
_podService.oauth2GetAccessToken(platform: 'twitter');
return true;
} catch (e) {
AppLogger.err(
'Error refreshing twitter access token ${e.toString()}');
}
// Authenticate again
return await _podService.webAuth();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment