summaryrefslogtreecommitdiff
path: root/imap
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2021-07-28 21:16:54 -0600
committerEduardo Chappa <chappa@washington.edu>2021-07-28 21:16:54 -0600
commitc39814e31d89bd14111347aadca9f0e225b8f06d (patch)
tree1ed9d2c5e790d3ece97739f04e73dea4d38b1488 /imap
parent816e148694cd483aae8206b6187fed8b0ddb9b13 (diff)
downloadalpine-c39814e31d89bd14111347aadca9f0e225b8f06d.tar.xz
* Print error when trying to authenticate using XOAUTH2, when available.
Diffstat (limited to 'imap')
-rw-r--r--imap/src/c-client/oauth2_aux.c22
1 files changed, 18 insertions, 4 deletions
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++;
}
}