From 5417727912422ac3d58f3cc3fd78c75b2a060fe3 Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Fri, 12 Jun 2020 20:33:58 -0600 Subject: * Additional addition of doucmentation for XOAUTH2, some fixes in the documentation, fixes in the configuration screen, and documentation on what is needed in each structure defining each service. --- imap/src/c-client/mail.h | 23 ++++++++++++++++------- imap/src/c-client/oauth2_aux.c | 6 ++++-- 2 files changed, 20 insertions(+), 9 deletions(-) (limited to 'imap/src/c-client') diff --git a/imap/src/c-client/mail.h b/imap/src/c-client/mail.h index 174fb9e3..f74d889d 100644 --- a/imap/src/c-client/mail.h +++ b/imap/src/c-client/mail.h @@ -1927,15 +1927,23 @@ int PFLUSH (void); #define OAUTH2_TOT_EQUIV (OAUTH2_MAX_EQUIV + 2) #define OAUTH2_PARAM_NUMBER (7) -typedef enum {OA2_Id = 0, OA2_Secret, OA2_Code, OA2_RefreshToken, - OA2_Scope, OA2_Redirect, - OA2_GrantTypeforAccessToken, OA2_GrantTypefromRefreshToken, - OA2_Response, OA2_State, OA2_Prompt, OA2_DeviceCode, OA2_End} OA2_type; - -typedef enum {OA2_GetAccessCode = 0, +typedef enum {OA2_Id = 0, + OA2_Secret, + OA2_Code, + OA2_RefreshToken, + OA2_Scope, + OA2_Redirect, + OA2_GrantTypeforAccessToken, + OA2_GrantTypefromRefreshToken, + OA2_Response, + OA2_State, + OA2_DeviceCode, + OA2_End} OA2_type; + +typedef enum {OA2_GetAccessCode = 0, /* define this to get access code */ + OA2_GetDeviceCode, /* define this if server uses device */ OA2_GetAccessTokenFromAccessCode, OA2_GetAccessTokenFromRefreshToken, - OA2_GetDeviceCode, OA2_GetEnd} OA2_function; typedef struct OA2_param_s { @@ -1968,6 +1976,7 @@ typedef struct oauth2_s { char *access_token; unsigned long expiration; unsigned int first_time:1; /* this is the first time we get credentials for this account */ + unsigned int require_secret:1; /* this server requires a client-secret */ } OAUTH2_S; typedef struct deviceproc_s { diff --git a/imap/src/c-client/oauth2_aux.c b/imap/src/c-client/oauth2_aux.c index 9ff14174..a23f7c28 100644 --- a/imap/src/c-client/oauth2_aux.c +++ b/imap/src/c-client/oauth2_aux.c @@ -90,7 +90,8 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method, char *s = NULL; JSON_S *json = NULL; - if(oauth2->param[OA2_Id].value == NULL || oauth2->param[OA2_Secret].value == NULL){ + if(oauth2->param[OA2_Id].value == NULL + || (oauth2->require_secret && oauth2->param[OA2_Secret].value == NULL)){ oauth2clientinfo_t ogci = (oauth2clientinfo_t) mail_parameters (NIL, GET_OA2CLIENTINFO, NIL); @@ -98,7 +99,8 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method, &oauth2->param[OA2_Secret].value); } - if (oauth2->param[OA2_Id].value == NULL || oauth2->param[OA2_Secret].value == NULL) + if(oauth2->param[OA2_Id].value == NULL + || (oauth2->require_secret && oauth2->param[OA2_Secret].value == NULL)) return; /* Do we have a method to execute? */ -- cgit v1.2.3-54-g00ecf