buffet: Do not remove credentials when invalid_grant. Change Buffet to not to remove credentials when gcd returns invalid_grant. The decision to remove credentials is handled outside buffet. This allows us to not to loose the device permanently in case of short duartion/temporary GAIA outage (similar to the one happened recently). BUG=b:37358256 TEST=Tested following scenarios on Gale 1. Factory reset from APP when Gale is online. 2. Factory reset from APP when Gale is offline. 3. Verify that the device reconnects back when credentials are removed from cloud and restored after 1 hour and device authenticates,reconnects successfully and operates normally there after. Change-Id: Iebf648738b9c91e59c17ec155baea6876db64d6a Reviewed-on: https://weave-review.googlesource.com/9990 Reviewed-by: Kan Yan <kyan@google.com>
diff --git a/src/device_registration_info.cc b/src/device_registration_info.cc index 3177a7d..ecd55c0 100644 --- a/src/device_registration_info.cc +++ b/src/device_registration_info.cc
@@ -354,10 +354,6 @@ if (!resp->GetString("error", &error_code)) { error_code = "unexpected_response"; } - if (error_code == "invalid_grant") { - LOG(INFO) << "The device's registration has been revoked."; - SetGcdState(GcdState::kInvalidCredentials); - } // I have never actually seen an error_description returned. if (!resp->GetString("error_description", &error_message)) { error_message = "Unexpected OAuth error"; @@ -778,13 +774,13 @@ void DeviceRegistrationInfo::CheckAccessTokenError(ErrorPtr error) { if (error && error->HasError(kErrorDomainOAuth2, "invalid_grant")) - RemoveCredentials(); + SetGcdState(GcdState::kInvalidCredentials); } void DeviceRegistrationInfo::ConnectToCloud(ErrorPtr error) { if (error) { if (error->HasError(kErrorDomainOAuth2, "invalid_grant")) - RemoveCredentials(); + SetGcdState(GcdState::kInvalidCredentials); return; }