From a0f68895abd9cf6c974f6918e04062868a12bd03 Mon Sep 17 00:00:00 2001 From: johnnyjoy Date: Wed, 14 May 2025 20:38:14 +0800 Subject: [PATCH] chore: add more logs for oauth2 --- plugin/idp/oauth2/oauth2.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/idp/oauth2/oauth2.go b/plugin/idp/oauth2/oauth2.go index 3ce29ce8..6d10075e 100644 --- a/plugin/idp/oauth2/oauth2.go +++ b/plugin/idp/oauth2/oauth2.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "io" + "log/slog" "net/http" "github.com/pkg/errors" @@ -86,11 +87,10 @@ func (p *IdentityProvider) UserInfo(token string) (*idp.IdentityProviderUserInfo defer resp.Body.Close() var claims map[string]any - err = json.Unmarshal(body, &claims) - if err != nil { + if err := json.Unmarshal(body, &claims); err != nil { return nil, errors.Wrap(err, "failed to unmarshal response body") } - + slog.Info("user info claims", "claims", claims) userInfo := &idp.IdentityProviderUserInfo{} if v, ok := claims[p.config.FieldMapping.Identifier].(string); ok { userInfo.Identifier = v @@ -118,5 +118,6 @@ func (p *IdentityProvider) UserInfo(token string) (*idp.IdentityProviderUserInfo userInfo.AvatarURL = v } } + slog.Info("user info", "userInfo", userInfo) return userInfo, nil }