getFromSavedCredentials method
dynamic
getFromSavedCredentials()
Implementation
getFromSavedCredentials() async {
Box box = await HiveService.getBox('credentials');
var json = box.get('json');
// If the OAuth2 credentials have already been saved from a previous run, we
// just want to reload them.
if (json != null) {
var credentials = new oauth2.Credentials.fromJson(json);
try {
_client = oauth2.Client(credentials,
identifier: GlobalVariables.identifier, secret: GlobalVariables.secret);
} on SocketException catch (e) {
dev.log('Socket Exception', name: libName, error: e);
return GlobalVariables.connectionTimeCode;
} on oauth2.AuthorizationException catch (e) {
dev.log('Auth Exception', name: libName, error: e);
return GlobalVariables.accessErrorCode;
} on FormatException catch (e) {
dev.log('Format Exception', name: libName, error: e);
return e.message;
}
GlobalVariables.token = _client!.credentials.accessToken;
return _client;
} else
return null;
}