diff options
Diffstat (limited to 'imap/src/c-client/auth_oa2.c')
-rw-r--r-- | imap/src/c-client/auth_oa2.c | 37 |
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 ea60f13..b003a65 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); } } |