Oauth2 认证库 在本地主机上运行良好,但在上传到 Google App Engine 时崩溃
当它执行上述代码的第 250 行时
r, err := (&http.Client{Transport: t.transport()}).PostForm(t.TokenURL, v)
错误响应是“权限被拒绝”
最佳答案
Since the Google App Engine URL Fetch API requires a per-request context, you must use the *plus.Service from within an HTTP handler. This package provides the WithNoAuthPlus and WithOAuthPlus functions which you can use to wrap your HTTP handlers to provide them with fully initialized *plus.Services.
例子:
c := appengine.NewContext(r)
trans := &oauth.Transport{
Config: oauthConfig,
Transport: &urlfetch.Transport{Context: c},
}
trans.Exchange(code)
resp, err := trans.Client().Get(profileInfoURL)
关于google-app-engine - 带有 GoLang "permission denied"错误的 Oauth2 身份验证的 Google App Engine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11226181/