google-app-engine - GOLANG HTTP Basic-Auth with Google App Engine URLFetch

标签 google-app-engine go

如何使用 Go 将 Authorization header 添加到 urlfetch 客户端?

javapython 也有类似的问题,但 Go 没有。

最佳答案

urlfetch.Client(ctx) 返回一个 HTTP 客户端 ( http://godoc.org/google.golang.org/appengine/urlfetch#Client )

http.ClientGetPost 等方法...它还有Do您可以提出任意请求。使用 http.NewRequest 创建一个请求:

req, err := http.NewRequest("GET", "http://www.google.com", nil)

然后你可以像这样添加一个标题:

req.Header.Set("Authorization", "whatever")

然后调用Do:

res, err := client.Do(req)

关于google-app-engine - GOLANG HTTP Basic-Auth with Google App Engine URLFetch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29871954/

相关文章:

google-app-engine - 将应用引擎端点部署到非默认版本

go - 如何在 golang 中模拟 GCP 的存储?

select - Go 中 select 语句的正确用法是什么?

go - 在读取和修改之前锁定 slice

python - BadValueError : Property X must be a str or unicode instance, 不是元组(更新时,而不是创建时)

python - 在 GAE/P 中创建您自己的事件日志

python - Appengine 将远程服务器数据下载到本地数据存储失败?

go - Golang 中结构体的静态成员

gorp PreUpdate 方法更新非自愿列

google-app-engine - 使用 Go 和 Datastore 查询数组