我有一个在Windows 10上用C++编写的自定义凭据帮助程序可执行文件。它基本上只是std::couts使用endl来指定用户名和密码:
std::cout << "username=myuser" << std::endl;
std::cout << "password=mypassword" << std::endl;
凭证助手已注册:
[credential "https://github.com/myuser/myrepo.git"]
helper = C:/Users/myuser/helper/GitCredentialManager.exe
凭证帮助程序被调用,但是无法通过远程身份验证(我测试了github和gitlab)
remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/myuser/myrepo.git'
2FA已禁用,我也尝试提供访问 token 而不是密码。
我也尝试使用printf代替std::cout。我叫std::cout.flush()
我做错了什么/我是否错过任何Windows特殊性?
这在macOS上可以正常工作。
最佳答案
您可能会缺少协议(protocol)行,如“Under the Hood”部分所示。
$ git credential fill (1)
protocol=https (2)
host=mygithost
(3)
protocol=https (4)
host=mygithost
username=bob
password=s3cre7
但是请不要忘记,您还有Microsoft Git Credential Manager for Mac and Linux,它将以安全的方式处理所有问题。
关于windows - 自定义git凭据帮助程序无法在Windows上进行身份验证,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/62131087/