diff --git a/connector/oidc/oidc.go b/connector/oidc/oidc.go index 4ec86a05..c8172811 100644 --- a/connector/oidc/oidc.go +++ b/connector/oidc/oidc.go @@ -301,10 +301,10 @@ func (c *oidcConnector) createIdentity(ctx context.Context, identity connector.I } hostedDomain, _ := claims["hd"].(string) - if c.preferredUsernameKey == "" { - c.preferredUsernameKey = "preferred_username" + preferredUsername, found := claims["preferred_username"].(string) + if !found { + preferredUsername, _ = claims[c.preferredUsernameKey].(string) } - preferredUsername, _ := claims[c.preferredUsernameKey].(string) if len(c.hostedDomains) > 0 { found := false