summaryrefslogtreecommitdiff
path: root/imap/src/c-client/auth_oa2.c
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2020-05-18 13:56:00 -0600
committerEduardo Chappa <chappa@washington.edu>2020-05-18 13:56:00 -0600
commit06f55d13682c0ac4b690bab7ca64f6caf5fd55bd (patch)
tree669f5831f1088d9567bba3c9532877d90d39c978 /imap/src/c-client/auth_oa2.c
parent1e6b822f3fa5bc17ceb94850c15bef643dda393d (diff)
downloadalpine-06f55d13682c0ac4b690bab7ca64f6caf5fd55bd.tar.xz
* A few improvements to the http code, which make the http_* functions not return the headers
of a http reply. So, http_get returns the text retrieved retrieverd, without headers. This allows for simplification of the mm_login_oauth2_c_client function.
Diffstat (limited to 'imap/src/c-client/auth_oa2.c')
-rw-r--r--imap/src/c-client/auth_oa2.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/imap/src/c-client/auth_oa2.c b/imap/src/c-client/auth_oa2.c
index ea60f13f..b003a653 100644
--- a/imap/src/c-client/auth_oa2.c
+++ b/imap/src/c-client/auth_oa2.c
@@ -265,9 +265,8 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method,
s = http_post_param2(RefreshMethod.urlserver, params);
if(s){
- unsigned char *t, *u;
- if((t = strstr(s, "\r\n\r\n")) && (u = strchr(t, '{')))
- json = json_parse(&u);
+ unsigned char *u = s;
+ json = json_parse(&u);
fs_give((void **) &s);
}
@@ -279,17 +278,8 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method,
oauth2->access_token = cpystr((char *) jx->value);
jx = json_body_value(json, "expires_in");
- if(jx){
- if(jx->jtype == JString){
- unsigned long *l = fs_get(sizeof(unsigned long));
- *l = atol((char *) jx->value);
- fs_give(&jx->value);
- jx->value = (void *) l;
- jx->jtype = JLong;
- }
- if(jx->jtype == JLong)
- oauth2->expiration = time(0) + *(unsigned long *) jx->value;
- }
+ if(jx && jx->jtype == JString)
+ oauth2->expiration = time(0) + atol((char *) jx->value);
json_free(&json);
}
@@ -333,9 +323,8 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method,
s = http_post_param2(RefreshMethod.urlserver, params);
if(s){
- unsigned char *t, *u;
- if((t = strstr(s, "\r\n\r\n")) && (u = strchr(t, '{')))
- json = json_parse(&u);
+ unsigned char *u = s;
+ json = json_parse(&u);
fs_give((void **) &s);
}
@@ -351,17 +340,9 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method,
oauth2->access_token = cpystr((char *) jx->value);
jx = json_body_value(json, "expires_in");
- if(jx){
- if(jx->jtype == JString){
- unsigned long *l = fs_get(sizeof(unsigned long));
- *l = atol((char *) jx->value);
- fs_give(&jx->value);
- jx->value = (void *) l;
- jx->jtype = JLong;
- }
- if(jx->jtype == JLong)
- oauth2->expiration = time(0) + *(unsigned long *) jx->value;
- }
+ if(jx && jx->jtype == JString)
+ oauth2->expiration = time(0) + atol((char *) jx->value);
+
json_free(&json);
}
}