[Commits] [SCM] claws branch, master, updated. 3.18.0-328-gc81b5638a
paul at claws-mail.org
paul at claws-mail.org
Thu Jan 13 10:22:15 UTC 2022
The branch, master has been updated
via c81b5638a8aa7507052b7b5312f5438e4cbb7053 (commit)
from f2a5429aec3db65c4932af5294ea8ecc6f255cb6 (commit)
Summary of changes:
src/oauth2.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit c81b5638a8aa7507052b7b5312f5438e4cbb7053
Author: paul <paul at claws-mail.org>
Date: Thu Jan 13 10:21:27 2022 +0000
improve the storage of refresh tokens for microsoft users
patch by David Fletcher
diff --git a/src/oauth2.c b/src/oauth2.c
index 29b40cedf..88c814c09 100644
--- a/src/oauth2.c
+++ b/src/oauth2.c
@@ -1,6 +1,6 @@
/*
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2021 the Claws Mail team
+ * Copyright (C) 2021-2022 the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -379,6 +379,7 @@ gint oauth2_use_refresh_token (Oauth2Service provider, OAUTH2Data *OAUTH2Data)
gchar *header;
gchar *tmp_hd, *tmp_hd_encoded;
gchar *access_token;
+ gchar *refresh_token;
gint expiry = 0;
gint ret;
SockInfo *sock;
@@ -406,6 +407,7 @@ gint oauth2_use_refresh_token (Oauth2Service provider, OAUTH2Data *OAUTH2Data)
}
access_token = g_malloc(OAUTH2BUFSIZE+1);
+ refresh_token = g_malloc(OAUTH2BUFSIZE+1);
request = g_malloc(OAUTH2BUFSIZE+1);
response = g_malloc(OAUTH2BUFSIZE+1);
@@ -480,6 +482,12 @@ gint oauth2_use_refresh_token (Oauth2Service provider, OAUTH2Data *OAUTH2Data)
ret = 1;
}
+ if (oauth2_filter_refresh (response, refresh_token) == 0) {
+ OAUTH2Data->refresh_token = g_strdup(refresh_token);
+ log_message(LOG_PROTOCOL, _("OAuth2 replacement refresh token provided\n"));
+ } else
+ log_message(LOG_PROTOCOL, _("OAuth2 replacement refresh token not provided\n"));
+
debug_print("OAuth2 - access token: %s\n", access_token);
debug_print("OAuth2 - access token expiry: %i\n", expiry);
@@ -491,6 +499,7 @@ gint oauth2_use_refresh_token (Oauth2Service provider, OAUTH2Data *OAUTH2Data)
g_free(client_id);
g_free(client_secret);
g_free(access_token);
+ g_free(refresh_token);
return (ret);
}
@@ -650,7 +659,9 @@ gint oauth2_check_passwds (PrefsAccount *ac_prefs)
if (ac_prefs->use_smtp_auth && ac_prefs->smtp_auth_type == SMTPAUTH_OAUTH2)
passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_SEND, OAUTH2Data->access_token, FALSE);
passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_EXPIRY, OAUTH2Data->expiry_str, FALSE);
- log_message(LOG_PROTOCOL, _("OAuth2 access token updated\n"));
+ //Some providers issue replacement refresh tokens with each access token. Re-store whether replaced or not.
+ passwd_store_set_account(ac_prefs->account_id, PWS_ACCOUNT_OAUTH2_REFRESH, OAUTH2Data->refresh_token, FALSE);
+ log_message(LOG_PROTOCOL, _("OAuth2 access and refresh token updated\n"));
}
g_free(OAUTH2Data);
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list