第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用go-git從GitHub Enterprise克隆存儲庫

使用go-git從GitHub Enterprise克隆存儲庫

Go
慕蓋茨4494581 2021-03-28 17:19:53
我試圖用來go-git從GitHub Enterprise克隆存儲庫。為此,我將HTTPS協(xié)議與訪問令牌一起使用,該訪問令牌對我的存儲庫具有適當(dāng)?shù)臋?quán)限(在命令行上已驗證)。go-git進(jìn)行g(shù)it-upload-packRPC調(diào)用時失敗,因為服務(wù)器響應(yīng)為400:$ go run main.gounexpected client error: unexpected requesting "https://github.mycompany.net/my-org/myrepo.git/info/refs?service=git-upload-pack" status code: 400它發(fā)出的請求與此等效:GET /my-org/myrepo.git/info/refs?service=git-upload-pack HTTP/1.1Host: github.mycompany.netUser-Agent: git/1.0Accept: */*Authorization: Bearer atokenthatisdefinitelyvalid在請求標(biāo)頭中沒有令牌的情況下,我Anonymous access denied從存儲庫中獲得了預(yù)期的401()響應(yīng)。有了令牌,它就會返回400。我發(fā)現(xiàn)非企業(yè)版GitHub上的公共存儲庫也是如此。區(qū)別在于它(沒有預(yù)期)可以在沒有Authorization標(biāo)題的情況下工作,因為沒有必要。如果我包含有效令牌,則GitHub與其企業(yè)版一樣會以400響應(yīng)。下面是一個最小的示例。有沒有一種方法可以go-git與需要認(rèn)證的GitHub Enterprise一起使用?理想情況下使用身份驗證令牌?package mainimport (    "fmt"    "io/ioutil"    git "gopkg.in/src-d/go-git.v4"    "gopkg.in/src-d/go-git.v4/plumbing"    "gopkg.in/src-d/go-git.v4/plumbing/transport/http")const (    repoURL           = "https://github.mycompany.net/my-org/myrepo.git"    githubAccessToken = "atokenthatisdefinitelyvalid")func main() {    dir, _ := ioutil.TempDir("", "temp_dir")    options := &git.CloneOptions{        Auth:          &http.TokenAuth{Token: githubAccessToken},        URL:           repoURL,        Depth:         500,        ReferenceName: plumbing.ReferenceName("refs/heads/master"),        SingleBranch:  true,        Tags:          git.NoTags,    }    _, err := git.PlainClone(dir, false, options)    fmt.Println(err)}
查看完整描述

2 回答

?
揚帆大魚

TA貢獻(xiàn)1799條經(jīng)驗 獲得超9個贊

事實證明,Github使用令牌作為您用戶的密碼,因此它需要基本身份驗證,而不是標(biāo)頭中的令牌:


options := &git.CloneOptions{

    Auth:          &http.BasicAuth{Username: "myusername", Token: "mytoken"},

    URL:           repoURL,

    Depth:         500,

    ReferenceName: plumbing.ReferenceName("refs/heads/master"),

    SingleBranch:  true,

    Tags:          git.NoTags,

}


查看完整回答
反對 回復(fù) 2021-04-19
  • 2 回答
  • 0 關(guān)注
  • 419 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號