Skip to content

Commit

Permalink
Fix: Login at web
Browse files Browse the repository at this point in the history
  • Loading branch information
timobaehr committed Mar 20, 2024
1 parent cd4996a commit af75550
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.14

* Login at web should work

## 0.0.13

* Improvement: CloudFile with getters fileId, fileName and mimeType
Expand Down
4 changes: 2 additions & 2 deletions lib/fl_cloud_storage/cloud_storage_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:logger/logger.dart';
/// Root logger.
final Logger log = Logger(
printer: MyPrinter('FL_CLOUD_STORAGE'),
level: Level.trace,
level: Level.verbose,
);

/// This class is the entrypoint for the fl_cloud_storage package. It is a
Expand Down Expand Up @@ -202,4 +202,4 @@ class CloudStorageService {
}
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,16 @@ class GoogleDriveService
final GoogleSignInAccount? account = await _getGoogleUser(googleSignIn);

final isAuthorizedForMobile = !kIsWeb && account != null;
final isAuthorizedForWeb = kIsWeb && account != null && await googleSignIn.canAccessScopes(googleSignIn.scopes);
final isAuthorizedForWeb = kIsWeb &&
account != null &&
await googleSignIn.canAccessScopes(googleSignIn.scopes);
if (!isAuthorizedForMobile && !isAuthorizedForWeb) {
throw Exception('User is not authorized!');
}

final GoogleSignInAuthentication googleAuth = await account.authentication;
_authenticationTokens = AuthenticationTokens(accessToken: googleAuth.accessToken, idToken: googleAuth.idToken);
_authenticationTokens = AuthenticationTokens(
accessToken: googleAuth.accessToken, idToken: googleAuth.idToken);

// set auth headers for the drive api
final Map<String, String> authHeaders = await account.authHeaders;
Expand Down Expand Up @@ -407,4 +410,4 @@ class GoogleDriveService
? GoogleDriveFolder(folder: res.files![0])
: null;
}
}
}

0 comments on commit af75550

Please sign in to comment.