X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/63fc8244f0ddecdbdacc21ab797acd2f466a2823..5fa3d9aa99f952d8ca032f94f9c47b739e2ef7e7:/h/oauth.h diff --git a/h/oauth.h b/h/oauth.h index d1c9c220..605008a1 100644 --- a/h/oauth.h +++ b/h/oauth.h @@ -1,13 +1,12 @@ -/* - * Implementation of OAuth 2.0 [1] for XOAUTH2 in SMTP [2] and POP3 [3]. +/* oauth.h -- OAuth 2.0 implementation for XOAUTH2 in SMTP and POP3. * * Google defined XOAUTH2 for SMTP, and that's what we use here. If other * providers implement XOAUTH2 or some similar OAuth-based SMTP authentication * protocol, it should be simple to extend this. * - * [1] https://tools.ietf.org/html/rfc6749 - * [2] https://developers.google.com/gmail/xoauth2_protocol - * [3] http://googleappsdeveloper.blogspot.com/2014/10/updates-on-authentication-for-gmail.html + * OAuth https://tools.ietf.org/html/rfc6749 + * SMTP https://developers.google.com/gmail/xoauth2_protocol + * POP3 http://googleappsdeveloper.blogspot.com/2014/10/updates-on-authentication-for-gmail.html * * Presumably [2] should document POP3 and that is an over-sight. As it stands, * that blog post is the closest we have to documentation. @@ -105,14 +104,18 @@ struct mh_oauth_service_info { * Do the complete dance for XOAUTH2 as used by POP3 and SMTP. * * Load tokens for svc from disk, refresh if necessary, and return the - * base64-encoded client response. + * client response in client_response and client_response_len. * * If refreshing, writes freshened tokens to disk. * * Exits via adios on any error. + * + * Always returns OK for now, but in the future could return NOTOK on error. */ -char * -mh_oauth_do_xoauth(const char *user, const char *svc, FILE *log); + +int +mh_oauth_do_xoauth(const char *user, const char *svc, unsigned char **oauth_res, + size_t *oauth_res_len, FILE *log); /* * Allocate and initialize a new OAuth context. @@ -218,7 +221,7 @@ mh_oauth_cred_free(mh_oauth_cred *cred); * Never returns NULL. */ const char * -mh_oauth_cred_fn(mh_oauth_ctx *ctx); +mh_oauth_cred_fn(const char *svc_name); /* * Serialize OAuth tokens to file. @@ -254,9 +257,6 @@ mh_oauth_sasl_client_response(size_t *res_len, * Retrieve the various entries for the OAuth mechanism */ -boolean +boolean mh_oauth_get_service_info(const char *svc_name, mh_oauth_service_info *svcinfo, char *errbuf, size_t errbuflen); - -char * -mh_oauth_node_name_for_svc(const char *entry, const char *svc_name);