From c39814e31d89bd14111347aadca9f0e225b8f06d Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Wed, 28 Jul 2021 21:16:54 -0600 Subject: * Print error when trying to authenticate using XOAUTH2, when available. --- imap/src/c-client/oauth2_aux.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'imap') diff --git a/imap/src/c-client/oauth2_aux.c b/imap/src/c-client/oauth2_aux.c index 0ecd0730..550f3b56 100644 --- a/imap/src/c-client/oauth2_aux.c +++ b/imap/src/c-client/oauth2_aux.c @@ -235,9 +235,16 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method, oauth2->cancel_refresh_token = 0; /* do not cancel this token. It is good */ break; - default : { char tmp[100]; - sprintf(tmp, "Oauth2 client Received Code %d", status); + default : { char tmp[200]; + char *err, *err_desc; + jx = json_body_value(json, "error"); + err = cpystr(jx && jx->jtype == JString ? (char *) jx->value : "Unknown error"); + jx = json_body_value(json, "error_description"); + err_desc = cpystr(jx && jx->jtype == JString ? (char *) jx->value : "No description"); + sprintf(tmp, "Code %d: %.80s: %.80s", status, err, err_desc); mm_log (tmp, ERROR); + if(err) fs_give((void **) &err); + if(err_desc) fs_give((void **) &err_desc); oauth2->cancel_refresh_token++; } break; @@ -302,9 +309,16 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method, case HTTP_BAD : break; - default : { char tmp[100]; - sprintf(tmp, "Oauth2 Client Received Code %d", status); + default : { char tmp[200]; + char *err, *err_desc; + jx = json_body_value(json, "error"); + err = cpystr(jx && jx->jtype == JString ? (char *) jx->value : "Unknown error"); + jx = json_body_value(json, "error_description"); + err_desc = cpystr(jx && jx->jtype == JString ? (char *) jx->value : "No description"); + sprintf(tmp, "Code %d: %.80s: %.80s", status, err, err_desc); mm_log (tmp, ERROR); + if(err) fs_give((void **) &err); + if(err_desc) fs_give((void **) &err_desc); oauth2->cancel_refresh_token++; } } -- cgit v1.2.3-70-g09d2