OAuth2身份验证中带有GoLang的Google App Engine“权限被拒绝”错误

Oauth2 autentification library Works well on the localhost but crashes when is uploaded to the Google App Engine

oauth.go

When it does the line 250 of the above code

r, err := (&http.Client{Transport: t.transport()}).PostForm(t.TokenURL, v)

The error response is "permission denied"

From the api.go documentation :

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.

Example:

c := appengine.NewContext(r)
trans := &oauth.Transport{
    Config:    oauthConfig,
    Transport: &urlfetch.Transport{Context: c},
}
trans.Exchange(code)
resp, err := trans.Client().Get(profileInfoURL)