summaryrefslogtreecommitdiff
path: root/imap
diff options
context:
space:
mode:
Diffstat (limited to 'imap')
-rw-r--r--imap/src/c-client/auth_oa2.c16
-rw-r--r--imap/src/c-client/mail.c7
-rw-r--r--imap/src/c-client/mail.h8
3 files changed, 22 insertions, 9 deletions
diff --git a/imap/src/c-client/auth_oa2.c b/imap/src/c-client/auth_oa2.c
index 907f722f..7ac1cb23 100644
--- a/imap/src/c-client/auth_oa2.c
+++ b/imap/src/c-client/auth_oa2.c
@@ -228,15 +228,17 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user,
char *s = NULL;
JSON_S *json = NULL;
- if(oauth2->param[OA2_Id].value == NULL
- || oauth2->param[OA2_Secret].value == NULL){
- /*
- * We need to implement client-side entering client_id and
- * client_secret, and other parameters. In the mean time, bail out.
- */
- return;
+ if(oauth2->param[OA2_Id].value == NULL || oauth2->param[OA2_Secret].value == NULL){
+ oauth2clientinfo_t ogci =
+ (oauth2clientinfo_t) mail_parameters (NIL, GET_OA2CLIENTINFO, NIL);
+
+ if(ogci) (*ogci)(oauth2->name, &oauth2->param[OA2_Id].value,
+ &oauth2->param[OA2_Secret].value);
}
+ if(oauth2->param[OA2_Id].value == NULL || oauth2->param[OA2_Secret].value == NULL)
+ return;
+
/* first check if we have a refresh token, and in that case use it */
if(oauth2->param[OA2_RefreshToken].value){
diff --git a/imap/src/c-client/mail.c b/imap/src/c-client/mail.c
index 7291a642..adddb9d4 100644
--- a/imap/src/c-client/mail.c
+++ b/imap/src/c-client/mail.c
@@ -91,6 +91,8 @@ static copyuid_t mailcopyuid = NIL;
static appenduid_t mailappenduid = NIL;
static oauth2getaccesscode_t oauth2getaccesscode = NIL;
+
+static oauth2clientinfo_t oauth2clientinfo = NIL;
/* free elt extra stuff callback */
static freeeltsparep_t mailfreeeltsparep = NIL;
/* free envelope extra stuff callback */
@@ -673,6 +675,11 @@ void *mail_parameters (MAILSTREAM *stream,long function,void *value)
case GET_OA2CLIENTGETACCESSCODE:
ret = (void *) oauth2getaccesscode;
break;
+ case SET_OA2CLIENTINFO:
+ oauth2clientinfo = (oauth2clientinfo_t) value;
+ case GET_OA2CLIENTINFO:
+ ret = (void *) oauth2clientinfo;
+ break;
default:
if ((r = smtp_parameters (function,value)) != NULL) ret = r;
if ((r = env_parameters (function,value)) != NULL) ret = r;
diff --git a/imap/src/c-client/mail.h b/imap/src/c-client/mail.h
index b5cd65d2..4cb35133 100644
--- a/imap/src/c-client/mail.h
+++ b/imap/src/c-client/mail.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2018 Eduardo Chappa
+ * Copyright 2016-2020 Eduardo Chappa
*
* Last Edited: July 21, 2018 Eduardo Chappa <chappa@washington.edu>
*
@@ -156,6 +156,8 @@
#define SET_IDSTREAM (long) 168
#define GET_OA2CLIENTGETACCESSCODE (long) 169
#define SET_OA2CLIENTGETACCESSCODE (long) 170
+#define GET_OA2CLIENTINFO (long) 171
+#define SET_OA2CLIENTINFO (long) 172
/* 2xx: environment */
#define GET_USERNAME (long) 201
@@ -1939,7 +1941,7 @@ typedef struct OA2_serverparam_s {
} OAUTH2_SERVER_METHOD_S;
typedef struct oauth2_s {
- char *name; /* provider name */
+ unsigned char *name; /* provider name */
char *host[OAUTH2_TOT_EQUIV]; /* servers for which this data applies */
OAUTH2_PARAM_S param[OA2_End]; /* parameters name and values for this server */
/* servers, methods and parameters to retrieve access code and tokens */
@@ -1949,3 +1951,5 @@ typedef struct oauth2_s {
} OAUTH2_S;
typedef char *(*oauth2getaccesscode_t) (char *url, OAUTH2_S *, int *);
+typedef void *(*oauth2clientinfo_t)(char *name, char **id, char **secret);
+