Created
May 8, 2025 23:04
-
-
Save Jamim/4c61eb842b7f5f2b184b829273de5aef to your computer and use it in GitHub Desktop.
Converting Apple's weird boolean to a normal one
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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