最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Unable to Retrieve gender and birthday from Google Identity Provider in Keycloak - Stack Overflow

programmeradmin0浏览0评论

I'm using Keycloak with Google as an Identity Provider. While I can successfully retrieve the user's name, email, and profile picture, I am unable to fetch the gender and birthday attributes.

What I’ve Tried:

  1. Added these scopes in Keycloak > Google Identity Provider > Advanced Settings:

    • .gender.read

    • .birthday.read

  2. Created gender and birthday mappers inside the Google Identity Provider settings in Keycloak.

  3. Added gender and birthday attributes in the User Profile under Realm Settings.

  4. Tested with OAuth 2.0 Playground, and I can successfully retrieve both gender and birthday there.

Issue:

When using Keycloak’s login interface with Google, I only get the following attributes:

  • Username

  • Email

  • First name

  • Last name

  • Profile picture

The gender and birthday are null.

What could be causing Keycloak to not retrieve these attributes, even though the scopes and mappers are correctly set up? Am I missing an additional configuration step in Keycloak?

I'm using Keycloak with Google as an Identity Provider. While I can successfully retrieve the user's name, email, and profile picture, I am unable to fetch the gender and birthday attributes.

What I’ve Tried:

  1. Added these scopes in Keycloak > Google Identity Provider > Advanced Settings:

    • https://www.googleapis.com/auth/user.gender.read

    • https://www.googleapis.com/auth/user.birthday.read

  2. Created gender and birthday mappers inside the Google Identity Provider settings in Keycloak.

  3. Added gender and birthday attributes in the User Profile under Realm Settings.

  4. Tested with OAuth 2.0 Playground, and I can successfully retrieve both gender and birthday there.

Issue:

When using Keycloak’s login interface with Google, I only get the following attributes:

  • Username

  • Email

  • First name

  • Last name

  • Profile picture

The gender and birthday are null.

What could be causing Keycloak to not retrieve these attributes, even though the scopes and mappers are correctly set up? Am I missing an additional configuration step in Keycloak?

Share Improve this question asked Feb 6 at 13:14 Tural KarimliTural Karimli 13 bronze badges New contributor Tural Karimli is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

2 Answers 2

Reset to default 0

Since your case is difficult to reproduce (especially without a detailed explanation of your exact setup), I can only make a guess.

Maybe birthday and gender info is set to Only you in your Google Account settings at https://myaccount.google.com/profile? When testing in the OAuth 2.0 Playground, you can see these details because you're accessing your own data, but this info may not be shared externally.

Add a custom event listener to Keycloak. This makes a request to the People API (https://people.googleapis.com/v1/people/me?personFields=genders,birthdays) when the user uses sign in with google, retrieves values, and adds them to the user info. That worked for me.

发布评论

评论列表(0)

  1. 暂无评论