Skip to content

Instantly share code, notes, and snippets.

@Jamim
Created May 8, 2025 23:04
Show Gist options
  • Select an option

  • Save Jamim/4c61eb842b7f5f2b184b829273de5aef to your computer and use it in GitHub Desktop.

Select an option

Save Jamim/4c61eb842b7f5f2b184b829273de5aef to your computer and use it in GitHub Desktop.
Converting Apple's weird boolean to a normal one
def apple_bool(email_verified: str | bool) -> bool:
"""Converts Apple's weird boolean to a normal one.
https://developer.apple.com/documentation/signinwithapple/authenticating-users-with-sign-in-with-apple
`email_verified` is a string or Boolean value that indicates whether
the service verifies the email. The value can either be a string
("true" or "false") or a Boolean (true or false). The system may
not verify email addresses for Sign in with Apple at Work & School users,
and this claim is "false" or false for those users.
"""
if isinstance(email_verified, bool):
return email_verified
return email_verified == 'true'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment