Search code examples
amazon-web-servicesamazon-cognitoaws-amplify

AWS Cognito Custom attribute is missing from ID token


I have a cognito userpool with a custom attribute. Attribute is mutable and the type is Boolean. But it is missing from the ID token

I tried following things

  • In App client explicitly made the attribute readable / writable
  • Unticked all the attributes to make them all readable / writable
  • Enabled OAuth scopes - Profile

None of them worked. How do I add custom attributes to the ID token?


Solution

  • Finally found a fix for this

    In my case, I did not receive the attribute as it did not contain any value. The attribute will only be included in the token only if it contains a value

    Important points found on research:

    • Make sure your attribute is readable. You can do this by visiting App clients -> Show details -> Set attribute read and write permissions (Insignificant link in the bottom.) -> tick your attribute that you want to be included in the token

    • If you are adding the attribute to an existing user pool, then you can not make it required.