From 8aab983ab6acccab729f164f238bcdf318cc03bb Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Wed, 31 Oct 2018 09:58:10 +0100 Subject: [PATCH] http: improve TokenAuth documentation Users are often confused with TokenAuth, since it might look that it should be used with GitHub's OAuth tokens. But that is not the case. TokenAuth implements HTTP bearer authentication. Most git servers will use HTTP basic authentication (user+passwords) even for OAuth tokens. Signed-off-by: Santiago M. Mola --- plumbing/transport/http/common.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plumbing/transport/http/common.go b/plumbing/transport/http/common.go index 2909a0682..5d3535e82 100644 --- a/plumbing/transport/http/common.go +++ b/plumbing/transport/http/common.go @@ -214,7 +214,14 @@ func (a *BasicAuth) String() string { return fmt.Sprintf("%s - %s:%s", a.Name(), a.Username, masked) } -// TokenAuth implements the go-git http.AuthMethod and transport.AuthMethod interfaces +// TokenAuth implements an http.AuthMethod that can be used with http transport +// to authenticate with HTTP token authentication (also known as bearer +// authentication). +// +// IMPORTANT: If you are looking to use OAuth tokens with popular servers (e.g. +// GitHub, Bitbucket, GitLab) you should use BasicAuth instead. These servers +// use basic HTTP authentication, with the OAuth token as user or password. +// Check the documentation of your git server for details. type TokenAuth struct { Token string }