{"thread":{"id":"51634","subject":"send-email and credential","startedAt":"2019-08-12T22:00:29Z","lastAt":"2019-08-12T22:25:49Z","messageCount":3,"participants":["D. Ben Knoble","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"380350","messageId":"CALnO6CDFQA_QmR_2tczPNJiymfUxt8LUiF0HOvKJKreB_HmNuQ@mail.gmail.com","threadId":"51634","inReplyTo":null,"subject":"send-email and credential","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2019-08-12T22:00:14Z","receivedAt":"2019-08-12T22:00:29Z","isPatch":false,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"Hello all,\n\nI spent a frustrating hour today hoping to setup git-send-email with\nmy gmail account. I've been able to confirm the following:\n\n1. git credential works\n\n    # git config credential.helper\n    osxkeychain\n    # git credential fill <<EOF\n    protocol=smtp\n    host=smtp.gmail.com\n    EOF\n\noutputs the correct username and password for my gmail account.\n\n2. I (believe) I setup gitconfig properly:\n\n    # git config --get-regexp sendemail\n    sendemail.smtpserver smtp.gmail.com\n    sendemail.smtpuser ben.knoble@gmail.com\n    sendemail.smtpencryption tls\n    sendemail.smtpserverport 587\n    sendemail.multiedit true\n    sendemail.annotate true\n\nThe strange behavior I'm seeing is that git-send-email\n\n- prompted me via macOS for keychain access (expected). This happened\ntwice in a row, during one command invocation.\n- prompted me at the terminal for my gmail password (shudders)\n- stopped prompting me for messages send after that (all within the 15\nminutes of the first two)\n\nCan anyone confirm/explain what's going on? I've never tried to use\ngit-credential or git-send-email before, so I'm new to those (but\nexperienced in git).\n\nD. Ben Knoble\n"},{"id":"380351","messageId":"20190812221828.GA16666@sigill.intra.peff.net","threadId":"51634","inReplyTo":"CALnO6CDFQA_QmR_2tczPNJiymfUxt8LUiF0HOvKJKreB_HmNuQ@mail.gmail.com","subject":"Re: send-email and credential","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-08-12T22:18:29Z","receivedAt":"2019-08-12T22:18:31Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Aug 12, 2019 at 06:00:14PM -0400, D. Ben Knoble wrote:\n\n> I spent a frustrating hour today hoping to setup git-send-email with\n> my gmail account. I've been able to confirm the following:\n> \n> 1. git credential works\n> \n>     # git config credential.helper\n>     osxkeychain\n>     # git credential fill <<EOF\n>     protocol=smtp\n>     host=smtp.gmail.com\n>     EOF\n> \n> outputs the correct username and password for my gmail account.\n> \n> 2. I (believe) I setup gitconfig properly:\n> \n>     # git config --get-regexp sendemail\n>     sendemail.smtpserver smtp.gmail.com\n>     sendemail.smtpuser ben.knoble@gmail.com\n>     sendemail.smtpencryption tls\n>     sendemail.smtpserverport 587\n>     sendemail.multiedit true\n>     sendemail.annotate true\n> \n> The strange behavior I'm seeing is that git-send-email\n> \n> - prompted me via macOS for keychain access (expected). This happened\n> twice in a row, during one command invocation.\n> - prompted me at the terminal for my gmail password (shudders)\n> - stopped prompting me for messages send after that (all within the 15\n> minutes of the first two)\n> \n> Can anyone confirm/explain what's going on? I've never tried to use\n> git-credential or git-send-email before, so I'm new to those (but\n> experienced in git).\n\nI don't think the saved password you're showing in step 1 is being\ntriggered, because Git will send \"smtp.gmail.com:587\" as the host field.\nTry this:\n\n  git \\\n    -c credential.helper='!exec >/tmp/credential.log 2>&1; cat; echo' \\\n    send-email ...\n\nwhich will log the helper request. It probably has:\n\n  host=smtp.gmail.com:587\n\nI don't remember the specifics of how osxkeychain works, but it probably\npulls the port out of that and passes it to the OS keychain code, which\nthen treats it as a separate service.\n\nSo the rest of the behavior makes sense, then, I think:\n\n  1. macOS had to unlock your keychain to check for the entry\n\n  2. finding nothing, Git prompted you for the password\n\n  3. Git then wrote the password to keychain after it was used\n     successfully (maybe prompting another keychain password request? I\n     don't know how it works), after which it should work without a\n     password.\n\n-Peff\n"},{"id":"380352","messageId":"CALnO6CDYBv+742=4Z0KbC0rgNA0KTdVR=deU7pPj6twHHpkgJg@mail.gmail.com","threadId":"51634","inReplyTo":"20190812221828.GA16666@sigill.intra.peff.net","subject":"Re: send-email and credential","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2019-08-12T22:25:32Z","receivedAt":"2019-08-12T22:25:49Z","isPatch":false,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"Peff is completely right: the log showed host=smpt.gmail.com:587 as\nexpected. Keychain confirms.\n\nThanks!\n\nD. Ben Knoble\n\nP.S. Be sure to delete /tmp/credential.log afterwards to clean up your\npasswords.\n\nOn Mon, Aug 12, 2019 at 6:18 PM Jeff King <peff@peff.net> wrote:\n>\n> On Mon, Aug 12, 2019 at 06:00:14PM -0400, D. Ben Knoble wrote:\n>\n> > I spent a frustrating hour today hoping to setup git-send-email with\n> > my gmail account. I've been able to confirm the following:\n> >\n> > 1. git credential works\n> >\n> >     # git config credential.helper\n> >     osxkeychain\n> >     # git credential fill <<EOF\n> >     protocol=smtp\n> >     host=smtp.gmail.com\n> >     EOF\n> >\n> > outputs the correct username and password for my gmail account.\n> >\n> > 2. I (believe) I setup gitconfig properly:\n> >\n> >     # git config --get-regexp sendemail\n> >     sendemail.smtpserver smtp.gmail.com\n> >     sendemail.smtpuser ben.knoble@gmail.com\n> >     sendemail.smtpencryption tls\n> >     sendemail.smtpserverport 587\n> >     sendemail.multiedit true\n> >     sendemail.annotate true\n> >\n> > The strange behavior I'm seeing is that git-send-email\n> >\n> > - prompted me via macOS for keychain access (expected). This happened\n> > twice in a row, during one command invocation.\n> > - prompted me at the terminal for my gmail password (shudders)\n> > - stopped prompting me for messages send after that (all within the 15\n> > minutes of the first two)\n> >\n> > Can anyone confirm/explain what's going on? I've never tried to use\n> > git-credential or git-send-email before, so I'm new to those (but\n> > experienced in git).\n>\n> I don't think the saved password you're showing in step 1 is being\n> triggered, because Git will send \"smtp.gmail.com:587\" as the host field.\n> Try this:\n>\n>   git \\\n>     -c credential.helper='!exec >/tmp/credential.log 2>&1; cat; echo' \\\n>     send-email ...\n>\n> which will log the helper request. It probably has:\n>\n>   host=smtp.gmail.com:587\n>\n> I don't remember the specifics of how osxkeychain works, but it probably\n> pulls the port out of that and passes it to the OS keychain code, which\n> then treats it as a separate service.\n>\n> So the rest of the behavior makes sense, then, I think:\n>\n>   1. macOS had to unlock your keychain to check for the entry\n>\n>   2. finding nothing, Git prompted you for the password\n>\n>   3. Git then wrote the password to keychain after it was used\n>      successfully (maybe prompting another keychain password request? I\n>      don't know how it works), after which it should work without a\n>      password.\n>\n> -Peff\n"}]}