| 981 | } |
| 982 | |
| 983 | static char *xoauth2_base64(const char *user, const char *access_token) |
| 984 | { |
| 985 | int b64_len; |
| 986 | char *raw, *b64; |
| 987 | |
| 988 | /* |
| 989 | * Compose the XOAUTH2 string |
| 990 | * "user=" {User} "^Aauth=Bearer " {Access Token} "^A^A" |
| 991 | * https://developers.google.com/workspace/gmail/imap/xoauth2-protocol#initial_client_response |
| 992 | */ |
| 993 | raw = xstrfmt("user=%s\001auth=Bearer %s\001\001", user, access_token); |
| 994 | |
| 995 | /* Base64 encode */ |
| 996 | b64 = xmallocz(ENCODED_SIZE(strlen(raw))); |
| 997 | b64_len = EVP_EncodeBlock((unsigned char *)b64, (unsigned char *)raw, strlen(raw)); |
| 998 | free(raw); |
| 999 | |
| 1000 | if (b64_len < 0) { |
| 1001 | free(b64); |
| 1002 | return NULL; |
| 1003 | } |
| 1004 | return b64; |
| 1005 | } |
| 1006 | |
| 1007 | static int auth_plain(struct imap_store *ctx, const char *prompt UNUSED) |
| 1008 | { |
no test coverage detected