ctx := context.Background()
insecureClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
ctx = context.WithValue(ctx, oauth2.HTTPClient, insecureClient)
client := oauth2.NewClient(ctx, oauth2.StaticTokenSource(&oauth2.Token{
AccessToken: c.Param("accesstoken"),
TokenType: "Bearer",
}))
resp, err := client.Get("https://ory-hydra-login-consent:9020/openid/userinfo")
if err != nil {
return newHTTPError(400, "InvalidToken", err.Error())
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return newHTTPError(400, "InvalidToken", err.Error())
}
c.Logger().Debugf("resp: %s", body)
var t map[string]interface{}
err = json.Unmarshal(body, &t)
if err != nil {
return newHTTPError(400, "InvalidToken", err.Error())
}
return c.JSON(http.StatusOK, t)
oauth2 NewClient InsecureSkipVerify
https://github.com/terraform-providers/terraform-provider-github/blob/master/github/config.go
oauth2 nodejs
https://peach.ebu.io/technical/tutorials/tuto-oauth2-client/
https://www.pveller.com/oauth2-with-passport-10-steps-recipe/
http://www.hitotec.com/authentification-oauth-avec-passportjs-pour-une-api-rest/
https://www.shangyang.me/2018/03/11/javascript-nodejs-passport-04-deepinto-oauth2-authenticate-process/
https://blog.yorkxin.org/2013/09/30/oauth2-4-1-auth-code-grant-flow.html
https://www.pveller.com/oauth2-with-passport-10-steps-recipe/
http://www.hitotec.com/authentification-oauth-avec-passportjs-pour-une-api-rest/
https://www.shangyang.me/2018/03/11/javascript-nodejs-passport-04-deepinto-oauth2-authenticate-process/
https://blog.yorkxin.org/2013/09/30/oauth2-4-1-auth-code-grant-flow.html
訂閱:
文章 (Atom)