getToken method
- @override
override
KO: 저장된 토큰 반환
EN: Returns saved tokens
Implementation
@override
Future<OAuthToken?> getToken() async {
if (_currentToken != null) {
return _currentToken;
}
_encryptor ??= await AESCipher.create();
_preferences ??= await SharedPreferences.getInstance();
var version = _preferences!.getString(versionKey);
var jsonToken = _preferences!.getString(tokenKey);
if (jsonToken == null || version == null) {
_currentToken = await _migrateOldToken();
} else {
try {
_currentToken =
OAuthToken.fromJson(jsonDecode(_encryptor!.decrypt(jsonToken)));
} catch (e) {
await clear();
SdkLog.e(
'A previously saved token was deleted due to an error during decryption. Please login again.');
}
}
return _currentToken;
}