logto-io / go

☁️ Logto Golang SDKs.
MIT License
19 stars 13 forks source link

feature request: #127

Closed edgarsilva closed 4 months ago

edgarsilva commented 4 months ago

What problem did you meet?

The IdToken JWT should include all the fields in the core.IdTokenClaims struct as returned by the logtoClient.GetIdTokenClaims() function. The parsed IdTokenClaims are confusing b/c they list them, but they are not actually included in the idtoken jwt response and are always blank.

Is there away to include them in the IdToken JWT response like withe Custom JWT Claims?

Describe what you'd like Logto to have

The IdToken JWT response should include all the listed fields, or the docs should say how to include them in the JWT. If not possible maybe remove them from the core.IdTokenClaims struct or create a diff struct, it is confusing to see them there and always be blank, in my case I was trying to use the user email and password and couldn't figure out why they were always blank.

edgarsilva commented 4 months ago

First of all congratulations to all the engineers involved with the Logto-io project and SDKs, it really is an amazing project and effort.

Found the answer here -> Logto Go Guide

Basically what you need to do is add the extra scopes in the logtoclient config like pP so:

    endpoint := os.Getenv("LOGTO_URL")
    appid := os.Getenv("LOGTO_APP_ID")
    appsecret := os.Getenv("LOGTO_APP_SECRET")
    return logto.LogtoConfig{
        Endpoint:  endpoint,
        AppId:     appid,
        AppSecret: appsecret,
        Scopes:    []string{"email", "phone", "picture", "custom_data"},
    }

That way when you call logtoclient.GetIdTokenClaims() it will be fully populated.

Once you find the correct docs is pressy easy, but It'll be great to have a guide on how to do this in a single place, I still don't know how to get the custom JWT token data, it is quite hard to piece it together from the diff sections of the docs.

I hope this helps someone else so they don't give up on Logto-io since it is an amazing piece of software, KUDOS to all the engineers involved in the project 👏, congrats and great work!