我正在為 google oauth2 https://github.com/golang/oauth2使用以下庫(kù)我正在使用示例中給出的代碼(網(wǎng)址:http : //play.golang.org/p/qXyuaVEhyS,https : //godoc.org/golang.org/x/oauth2/google)我能夠獲取授權(quán)碼和令牌,但無(wú)法發(fā)出獲取用戶(hù)信息的請(qǐng)求我的代碼:conf := &oauth2.Config{ ClientID: "my client id", ClientSecret: "secred id", RedirectURL: "http://localhost:3000/googlelogin", Scopes: []string{ "https://www.googleapis.com/auth/userinfo.profile", }, Endpoint: google.Endpoint, }m.Get("/googleloginrequest", func(r render.Render, request *http.Request) { url := conf.AuthCodeURL("state") fmt.Printf("Visit the URL for the auth dialog: %v", url) r.Redirect(url)})m.Get("/googlelogin", func(r render.Render, request *http.Request) { authcode := request.FormValue("code") tok, err := conf.Exchange(oauth2.NoContext, authcode) if err != nil { log.Fatal(err) } client := conf.Client(oauth2.NoContext, tok) resp, err :=client.Get("https://www.googleapis.com/userinfo/v2/me") r.JSON(200, map[string]interface{}{"status":resp}) })我在這里得到的回應(yīng)非常大而且沒(méi)有任何用戶(hù)信息
- 1 回答
- 0 關(guān)注
- 358 瀏覽
添加回答
舉報(bào)
0/150
提交
取消