查看 go-vcr 的设置
// Start our recorder
r, err := recorder.New("fixtures/etcd")
if err != nil {
log.Fatal(err)
}
defer r.Stop() // Make sure recorder is stopped once done with it
// Create an etcd configuration using our transport
cfg := client.Config{
Endpoints: []string{"http://127.0.0.1:2379"},
HeaderTimeoutPerRequest: time.Second,
Transport: r, // Inject as transport!
}
尝试使用 githubv4 库来使用这个库似乎需要一种方法来处理 Oauth
import "golang.org/x/oauth2"
func main() {
src := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
)
httpClient := oauth2.NewClient(context.Background(), src)
client := githubv4.NewClient(httpClient)
// Use client...
}
我不确定如何将记录器“r”放入 oauth2 客户端。如果可能的话。
有人成功过吗?我试过使用“r”记录器传递一个 httpClient,但它最终显示为 401 - 看起来这个默认客户端无法执行 Oauth 舞蹈。
我想使用 GraphQL API,但如果更容易的话可以回退到 REST API,但我只是想确保这真的不可能。还有其他人成功了吗?
www说
长风秋雁
随时随地看视频慕课网APP
相关分类