MCPcopy Create free account
hub / github.com/git/git / xoauth2_base64

Function xoauth2_base64

imap-send.c:983–1005  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

981}
982
983static 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
1007static int auth_plain(struct imap_store *ctx, const char *prompt UNUSED)
1008{

Callers 1

auth_xoauth2Function · 0.85

Calls 2

xstrfmtFunction · 0.85
xmalloczFunction · 0.85

Tested by

no test coverage detected