Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Expose network error
  • Loading branch information
Yuwen Yan committed Dec 11, 2019
commit e79d4e5503d269ecd7d2fae1fda2fa45ff6763fd
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public static final class Delegate implements IDelegate, PluginRegistry.Activity
// These error codes must match with ones declared on iOS and Dart sides.
private static final String ERROR_REASON_SIGN_IN_CANCELED = "sign_in_canceled";
private static final String ERROR_REASON_SIGN_IN_REQUIRED = "sign_in_required";
private static final String ERROR_REASON_NETWORK_ERROR = "network_error";
private static final String ERROR_REASON_SIGN_IN_FAILED = "sign_in_failed";
private static final String ERROR_FAILURE_TO_RECOVER_AUTH = "failed_to_recover_auth";
private static final String ERROR_USER_RECOVERABLE_AUTH = "user_recoverable_auth";
Expand Down Expand Up @@ -372,6 +373,8 @@ private String errorCodeForStatus(int statusCode) {
return ERROR_REASON_SIGN_IN_CANCELED;
} else if (statusCode == CommonStatusCodes.SIGN_IN_REQUIRED) {
return ERROR_REASON_SIGN_IN_REQUIRED;
} else if (statusCode == CommonStatusCodes.NETWORK_ERROR) {
return ERROR_REASON_NETWORK_ERROR;
} else {
return ERROR_REASON_SIGN_IN_FAILED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// These error codes must match with ones declared on Android and Dart sides.
static NSString *const kErrorReasonSignInRequired = @"sign_in_required";
static NSString *const kErrorReasonSignInCanceled = @"sign_in_canceled";
static NSString *const kErrorReasonNetworkError = @"network_error";
static NSString *const kErrorReasonSignInFailed = @"sign_in_failed";

static FlutterError *getFlutterError(NSError *error) {
Expand All @@ -21,6 +22,8 @@
errorCode = kErrorReasonSignInRequired;
} else if (error.code == kGIDSignInErrorCodeCanceled) {
errorCode = kErrorReasonSignInCanceled;
} else if ([error.domain isEqualToString:NSURLErrorDomain]) {
errorCode = kErrorReasonNetworkError;
} else {
errorCode = kErrorReasonSignInFailed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ class GoogleSignIn {
/// user.
static const String kSignInCanceledError = 'sign_in_canceled';

/// Error code indicating network error. Retrying should resolve the problem.
static const String kNetworkError = 'network_error';

/// Error code indicating that attempt to sign in failed.
static const String kSignInFailedError = 'sign_in_failed';

Expand Down Expand Up @@ -309,8 +312,9 @@ class GoogleSignIn {
///
/// When [suppressErrors] is set to `false` and an error occurred during sign in
/// returned Future completes with [PlatformException] whose `code` can be
/// either [kSignInRequiredError] (when there is no authenticated user) or
/// [kSignInFailedError] (when an unknown error occurred).
/// one of [kSignInRequiredError] (when there is no authenticated user) ,
/// [kNetworkError] (when a network error occurred) or [kSignInFailedError]
/// (when an unknown error occurred).
Future<GoogleSignInAccount> signInSilently({
bool suppressErrors = true,
}) async {
Expand Down