Hi Julian. The patch looks good. Please could you add instructions how to test it? Which servers have you tested? I have a gmail.com account. I configured Git following https://git-scm.com/docs/git-send-email#_use_gmail_as_the_smtp_server [sendemail] smtpEncryption = tls smtpServer = smtp.gmail.com smtpUser = yourname@xxxxxxxxx smtpServerPort = 587 And configured git-credential-oauth following https://github.com/hickford/git-credential-oauth/issues/48#issuecomment-1966486513 [credential "smtp://smtp.gmail.com:587"] oauthClientId = 406964657835-aq8lmia8j95dhl1a2bvharmfk3t1hgqj.apps.googleusercontent.com oauthClientSecret = kSmqreRr0qwBWJgbf5Y-PjSU oauthScopes = https://mail.google.com/ oauthAuthURL = https://accounts.google.com/o/oauth2/auth oauthTokenURL = https://oauth2.googleapis.com/token Then tested with: git send-email --smtp-auth=XOAUTH2 --smtp-debug=1 message.txt "git credential" was queried for an OAuth access token as expected. Note that Gmail access tokens are very long (~220 characters). However smtp.gmail.com responded authentication error "535-5.7.8 Username and Password not accepted". Looking at the debug information, it looks like the SMTP command "AUTH XOAUTH2 <base64>" was corrupted by a space at column 241. Exactly one base64 string should follow "AUTH XOAUTH2 ", no spaces. The same problem occurs with OAUTHBEARER: git send-email --smtp-auth=OAUTHBEARER --smtp-debug=1 message.txt I can reproduce this with any sufficiently long combination of user and pass, such as: git send-email --smtp-auth=XOAUTH2 --smtp-user=tim.arsietonarsei@xxxxxxxxxxx --smtp-pass=arsteiarositanrestnerastarstarstarstarstarsetnrasetnearstrasitenarseitnerasntearnstenarsetnearstarstearsetnariestnearsntenarestnerast --smtp-encryption=tls --smtp-server-port=587 --smtp-server=smtp.gmail.com --smtp-debug=1 message.txt Can you reproduce this problem? Any ideas? I think the bug must be in the call to Net::SMTP.