ĐARK々MÁTTER
ĐARK々MÁTTER14mo ago

How to get the user information from the token?

During callback from the authorize endpoint I exchange the code with token endpoint which gives me access_token, refresh_token and id_token. I have tried with all 3 tokens here, I am getting error https://zitadel.com/docs/apis/resources/auth/auth-service-get-my-user
{"code":16,"message":"Errors.Token.Invalid (AUTH-7fs1e)","details":[{"@type":"type.googleapis.com/zitadel.v1.ErrorDetail","id":"AUTH-7fs1e","message":"Errors.Token.Invalid"}]}%
{"code":16,"message":"Errors.Token.Invalid (AUTH-7fs1e)","details":[{"@type":"type.googleapis.com/zitadel.v1.ErrorDetail","id":"AUTH-7fs1e","message":"Errors.Token.Invalid"}]}%
The user is signedin fromthe google external provider.
ZITADEL Docs
Returns the full user object of the authenticated user including the profile, email, phone, etc
4 Replies
wlinna
wlinna14mo ago
Is there a reason you are not using the standard oidc userinfo endpoint for that? On localhost the url looks something like this: http://localhost:4444/oidc/v1/userinfo https://zitadel.com/docs/apis/openidoauth/endpoints
ZITADEL Docs
OpenID Connect 1.0 Discovery
wlinna
wlinna14mo ago
It's also possible to enable "User Info inside ID Token" in application settings if you don't want to make a separate query for userinfo
ĐARK々MÁTTER
ĐARK々MÁTTEROP14mo ago
Yes but I wanted to list user sessions on my app, that can't be achieved though this
FFO
FFO13mo ago
Try adding the scope urn:zitadel:iam:org:project:id:zitadel:aud this should add the aud of zitadel to the token so that they can be used against the api

Did you find this page helpful?