[geary/mjog/966-goa-retry-ensure-creds] GoaMediator: Re-try calling EnsureCredentials if auth error occurs
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/966-goa-retry-ensure-creds] GoaMediator: Re-try calling EnsureCredentials if auth error occurs
- Date: Wed, 2 Sep 2020 01:26:42 +0000 (UTC)
commit 17a7ad7eee510d5f9667c873d46e25f4ba587cd7
Author: Michael Gratton <mike vee net>
Date: Wed Sep 2 11:23:22 2020 +1000
GoaMediator: Re-try calling EnsureCredentials if auth error occurs
Per GOA docs, if that calls fails with an auth error, we need to try
it again.
See #966
src/client/application/goa-mediator.vala | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/client/application/goa-mediator.vala b/src/client/application/goa-mediator.vala
index baac0e6e6..bf92bb864 100644
--- a/src/client/application/goa-mediator.vala
+++ b/src/client/application/goa-mediator.vala
@@ -50,9 +50,23 @@ public class GoaMediator : Geary.CredentialsMediator, Object {
Geary.ServiceInformation service,
Cancellable? cancellable)
throws GLib.Error {
- yield this.handle.get_account().call_ensure_credentials(
- cancellable, null
- );
+ // Per GOA docs
+ // <https://developer.gnome.org/goa/stable/ch01s03.html>:
+ // "First the application should invoke the
+ // Account.EnsureCredentials() method […] if the service
+ // returns an authorization error (say, the access token
+ // expired), the application should call
+ // Account.EnsureCredentials() again to e.g. renew the
+ // credentials."
+ Goa.Account? goa_account = this.handle.get_account();
+ if (account != null) {
+ try {
+ yield goa_account.call_ensure_credentials(cancellable, null);
+ } catch (Goa.Error.NOT_AUTHORIZED err) {
+ debug("GOA updating auth failed, retrying: %s", err.message);
+ yield goa_account.call_ensure_credentials(cancellable, null);
+ }
+ }
bool loaded = false;
string? token = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]