Apple DeviceCheck API. Reduce fraudulent use of your services by managing device state and asserting app integrity.
Slowing down. Last release over 2 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install devicecheckApple DeviceCheck
Accessing and Modifying Per-Device Data
Use a token from your app to validate requests, query and modify two per-device binary digits stored on Apple servers.
Features
- Prevent API & Content abuse with validating requests via Apple device token
- Query and modify two bits of data to achieve up to four remote states saved on Apple servers
- Easy to use configuration
- Examples
- Integrations with modern web frameworks
Prepare
Visit https://developer.apple.com/account/resources/authkeys/list and create new Key with DeviceCheck permission
Install
pip install devicecheck
Usage (Python)
Setup
from devicecheck import DeviceCheck
device_check = DeviceCheck(
team_id="XX7AN23E0Z", # https://developer.apple.com/account/#/membership/
bundle_id="com.akentev.app",
key_id="JSAD983ENA", # Generated at https://developer.apple.com/account/resources/authkeys/list
private_key="/path/to/AuthKey_JSAD983ENA.p8",
# Generated file at https://developer.apple.com/account/resources/authkeys/list
dev_environment=True, # True if using development Apple environment, False if using in production.
# Remember to set dev_environment=False in production!
)
Asyncio setup
from devicecheck.asyncio import AsyncioDeviceCheck
The rest will be the same, except for network methods must be await'ed
Validate device
result = device_check.validate_device_token(device_token)
if result.is_ok:
print('OK! Device is valid')
else:
print('Bad news. Unable to validate device')
Update bits data
# Can use both integers, strings and booleans. Will be converted with bool(value)
result = device_check.update_two_bits(device_token, bit_0=1, bit_1=False)
# Can update bits separately
result = device_check.update_two_bits(device_token, bit_0=True)
if result.is_ok:
print('Bits updated')
else:
print(f'Something went wrong. {result}')