This release is a pre-release and may not be stable for production use.
pyxpo-apple-authentication
Sign in with Apple for pyxpo apps written in Python. The API follows expo-apple-authentication. It runs on iOS with AuthenticationServices. You get an identity token (a JWT signed by Apple) to verify on your server.
import pyxpo_apple_authentication as AppleAuthentication
from pyxpo_apple_authentication import AppleAuthenticationScope, AppleAuthenticationError
if await AppleAuthentication.is_available_async():
try:
cred = await AppleAuthentication.sign_in_async(
requested_scopes=[AppleAuthenticationScope.FULL_NAME, AppleAuthenticationScope.EMAIL])
await api.post("/auth/apple", {"identityToken": cred["identityToken"]})
except AppleAuthenticationError as e:
if e.code != "ERR_REQUEST_CANCELED":
raise
Features
- Apple's own sheet, with Face ID and the Hide My Email relay.
- Clear errors:
AppleAuthenticationError.codeisERR_REQUEST_CANCELEDwhen the user closes the sheet. - Apple's own button,
AppleAuthenticationButton, a nativeASAuthorizationAppleIDButton(sign in, continue or sign up; black, white or white outline; corner radius). - Every operation: sign in, refresh (new tokens for a known user) and sign out.
- Revocation:
get_credential_state_asyncandadd_revoke_listener, so you can sign out a user who stopped using Apple ID with your app in Settings. - Name formatting with
format_full_name_async, in the user's locale order. - Config plugin for the
com.apple.developer.applesigninentitlement, so you never edit the entitlements file. - Safe on every platform:
is_available_async()isFalseon Android, the web and the desktop. - camelCase too:
signInAsync(requestedScopes=...).
Contents
| If you are... | Start here |
|---|---|
| Setting up | Install · Apple Developer setup |
| Signing users in | Quick start |
| Exact names | API reference · Errors |
| Stuck | Testing · Troubleshooting |
Install
pip install pyxpo-apple-authentication
Add the module and its config plugin to your app's pyproject.toml:
[tool.pyxpo]
modules = ["apple-authentication"]
plugins = ["pyxpo_apple_authentication.plugin"]
Then rebuild the iOS app (pyxpo run ios). The plugin adds com.apple.developer.applesignin = ["Default"] to the
app entitlements.
| Platform | Engine | Minimum |
|---|---|---|
| iOS | AuthenticationServices | iOS 13 |
| Android, web, desktop | not supported (is_available_async() is False) |
Apple Developer setup
- In Certificates, Identifiers & Profiles, open your App ID and turn on Sign in with Apple.
- Make a new provisioning profile for that App ID, or let Xcode signing make it.
- On your server, verify
identityTokenagainst Apple's keys athttps://appleid.apple.com/auth/keys. Check thataudis your bundle ID andissishttps://appleid.apple.com.
The simulator needs an Apple ID signed in under Settings.
Quick start
Apple sends fullName and email only on the first sign-in of a user for your app. Send them to your server
then, with the token:
cred = await AppleAuthentication.sign_in_async(
requested_scopes=[AppleAuthenticationScope.FULL_NAME, AppleAuthenticationScope.EMAIL])
name = cred["fullName"] or {}
full = " ".join(p for p in (name.get("givenName"), name.get("familyName")) if p) or None
await api.post("/auth/apple", {"identityToken": cred["identityToken"], "fullName": full})
Check later that the user still allows your app:
from pyxpo_apple_authentication import AppleAuthenticationCredentialState as State
if await AppleAuthentication.get_credential_state_async(saved_user) is State.REVOKED:
await sign_out()
Or listen for it, and sign out at once:
sub = AppleAuthentication.add_revoke_listener(lambda: spawn(sign_out()))
# later: sub.remove()
Show Apple's own button. App Store review expects it (or one that follows the Human Interface Guidelines):
from pyxpo.module_api import spawn
from pyxpo_apple_authentication import (AppleAuthenticationButton, AppleAuthenticationButtonStyle,
AppleAuthenticationButtonType)
AppleAuthenticationButton(
button_type=AppleAuthenticationButtonType.CONTINUE,
button_style=AppleAuthenticationButtonStyle.BLACK,
corner_radius=10,
style={"width": 280, "height": 48},
on_press=lambda _: spawn(sign_in()),
)
It renders an empty view on other platforms, so show it only when is_available_async() is True.
Get fresh tokens for a user you know, and format the name you saved:
cred = await AppleAuthentication.refresh_async(saved_user)
label = await AppleAuthentication.format_full_name_async(saved_name, AppleAuthenticationFullNameFormatStyle.MEDIUM)
API reference
| Name | Returns | Notes |
|---|---|---|
is_available_async() |
bool |
True on iOS with the module linked. |
sign_in_async(requested_scopes=None, state=None, nonce=None, requested_operation=LOGIN) |
credential dict |
Shows Apple's sheet. |
refresh_async(user, requested_scopes=None, state=None) |
credential dict |
New tokens for a known user. |
sign_out_async(user, state=None) |
credential dict |
Apple's logout operation. End your server session too. |
get_credential_state_async(user) |
AppleAuthenticationCredentialState |
user is credential["user"]. |
add_revoke_listener(listener) |
Subscription |
listener() runs when the user revokes the app. .remove() stops it. |
format_full_name_async(full_name, format_style=DEFAULT) |
str |
iOS uses PersonNameComponentsFormatter. |
AppleAuthenticationButton(button_type, button_style, corner_radius, on_press, style) |
element | Default height 44. |
AppleAuthenticationOperation |
IMPLICIT, LOGIN, REFRESH, LOGOUT |
|
AppleAuthenticationButtonType |
SIGN_IN, CONTINUE, SIGN_UP |
|
AppleAuthenticationButtonStyle |
WHITE, WHITE_OUTLINE, BLACK |
|
AppleAuthenticationFullNameFormatStyle |
DEFAULT, SHORT, MEDIUM, LONG, ABBREVIATED |
|
AppleAuthenticationScope |
FULL_NAME, EMAIL |
|
AppleAuthenticationCredentialState |
REVOKED, AUTHORIZED, NOT_FOUND, TRANSFERRED |
|
AppleAuthenticationUserDetectionStatus |
UNSUPPORTED, UNKNOWN, LIKELY_REAL |
credential["realUserStatus"] |
The credential has user, state, fullName (namePrefix, givenName, middleName, familyName,
nameSuffix, nickname, or None), email, realUserStatus, identityToken and authorizationCode.
Errors
AppleAuthenticationError has code:
| Code | Meaning |
|---|---|
ERR_REQUEST_CANCELED |
The user closed the sheet. |
ERR_REQUEST_FAILED |
The request failed, for example with no Apple ID on the device. |
ERR_INVALID_RESPONSE |
Apple sent an answer without a user. |
ERR_REQUEST_NOT_HANDLED |
No provider handled the request. |
ERR_REQUEST_NOT_INTERACTIVE |
The request needed UI that the app cannot show now. |
ERR_IN_PROGRESS |
A sign-in is already open. |
ERR_REQUEST_UNKNOWN |
Anything else. |
On other platforms sign_in_async, refresh_async and sign_out_async raise pyxpo.module_api.NotSupportedError.
Testing
Use FakeBridge from pyxpo to run your sign-in logic on the desktop:
from pyxpo.module_testing import FakeBridge
import pyxpo_apple_authentication as A
def test_sign_in():
with FakeBridge("ios") as fb:
fb.on("AppleAuthentication", "signIn", lambda o: {"user": "001.a", "identityToken": "t"})
assert asyncio.run(A.sign_in_async())["identityToken"] == "t"
Troubleshooting
ERR_REQUEST_UNKNOWNwith error 1000. The entitlement is missing. Add the plugin and rebuild, and turn on Sign in with Apple for the App ID.fullNameisNone. It comes only on the first sign-in. Remove the app under Settings > Apple ID > Sign in with Apple to test it again.- Simulator: nothing happens. Sign in to an Apple ID in the simulator's Settings.
License
MIT
Metadata
Release files for pyxpo-apple-authentication 0.1.0a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyxpo_apple_authentication-0.1.0a2.tar.gz | 17.5 kB | With provenance | Details for pyxpo_apple_authentication-0.1.0a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyxpo_apple_authentication-0.1.0a2-py3-none-any.whl | Python 3 | none | any | Details for pyxpo_apple_authentication-0.1.0a2-py3-none-any.whl |
Total release size: 32.1 kB
Release files / pyxpo_apple_authentication-0.1.0a2.tar.gz
| Download URL | pyxpo_apple_authentication-0.1.0a2.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cfad14803dcd24d11a792f98ef85a0482286abe02fd9e9fe473033afc75995e8
|
|
BLAKE2b-256 checksum How to use checksums |
89d167b50b7d4163899c5bb185d85e501f200a1564a3e982429fd0a0bfae1b45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logRelease files / pyxpo_apple_authentication-0.1.0a2-py3-none-any.whl
| Download URL | pyxpo_apple_authentication-0.1.0a2-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e3368fb8ddab1001281fa970e4e41bcde0be07a06314d1e8fa07158e1bb5bfa0
|
|
BLAKE2b-256 checksum How to use checksums |
55cd3eea5f497def6c34fbeec256d3456ceb902911617252f08c9700bb2e7f92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logSecurity for pyxpo-apple-authentication 0.1.0a2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pyxpo_apple_authentication-0.1.0a2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.