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

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

為 OAuth2 提供程序正確的 AppEngine Golang 包

為 OAuth2 提供程序正確的 AppEngine Golang 包

Go
一只萌萌小番薯 2022-01-17 18:46:15
使用 OAuth 的正確方法是什么如果我使用context.Contextfrom golang.org/x/net/context,錯誤是:"golang.org/x/net/context".Context does not implement "appengine".Context (missing Call method)但如果我appengine.Context從appengine(SDK)使用,錯誤是:cannot use oauth2.NewClient(c) (type *http.Client) as type "golang.org/x/net/context".Context in argument to provider.Client:*http.Client does not implement "golang.org/x/net/context".Context (missing Deadline method)如果我使用oauth2.NoContext,運行時錯誤是Post https://accounts.google.com/o/oauth2/token: not an App Engine context都使用 Go 1.4 和 1.7b3 進行了測試使用這段代碼:func Public_YoutubeOauth(w http.ResponseWriter, r *http.Request) {    c := appengine.NewContext(r)    provider, csrf := getOAuth(r)    gets, err := url.ParseQuery(r.URL.RawQuery)    if RenderHtmlIfError(w,err) {        return    }    if csrf != gets.Get(`state`) {        RenderHtmlError(w,`incorrect CSRF state`)        return    }    code := gets.Get(`code`)    token, err := provider.Exchange(c, code) // error here    if RenderHtmlIfError(w,err) {        return    }    RenderHtml(w,`page`,map[string]interface{`token`:token})}是provider:&oauth2.Config{        ClientID:     `aaa`,        ClientSecret: `bbb`,        RedirectURL:  url + `/foo/youtube_oauth`,        Scopes: []string{            `openid`,            `email`,            `profile`,            `https://www.googleapis.com/auth/youtube`,        },        Endpoint: google.Endpoint,    }解決這個問題的正確方法是什么?
查看完整描述

1 回答

?
溫溫醬

TA貢獻1752條經(jīng)驗 獲得超4個贊

解決方案:

  1. 將所有"appengine導(dǎo)入更改為"google.golang.org/appengine

  2. 繼續(xù)使用context.Context(from golang.org/x/net/context) 而不是appengine.Context


查看完整回答
反對 回復(fù) 2022-01-17
  • 1 回答
  • 0 關(guān)注
  • 182 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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