Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Verify JWS-attestations from Google's SafetyNet.

Project description


A package for verifying JWS-attestations from Google's SafetyNet.


This package verifies SafetyNet attestations by following the steps described on the page. It allows you to specify what parts of the JWS-body you wish to verify, but will always atleast verify the certificate and validity of the JWS.


Online verification

from safetynet_attestation import Attestation

jws_token = "..."
api_key = "..."

attestation = Attestation(jws_token)

verify_online takes the following optional parameters:

  • url="<standard url>"
    • If you for some reason wish to validate against some other url.

<standard url> can be found at Google's SafetyNet documentation.

Offline verification

from safetynet_attestation import Attestation

jws_token = "..."

attestation = Attestation(jws_token)

verify_offline takes the following optional parameters:

  • apkPackageName=None

  • nonce=None

  • apkDigestSha256=None

    • str of hex-values.
  • apkCertificateDigestSha256=None

    • Can be list of str or str.
  • check_basicIntegrity=True

  • check_ctsProfileMatch=True

  • hostname=""

    • Used for TLS validation of the certificate. Only modify if you know what you are doing.

A full explanation of the parameters above can be found at Google's SafetyNet documentation

Once a token has been verified, the following fields can be used:

  • header

    • A dictof the token's header.
  • body

    • A dict of the token's body.
  • certificates

    • A listof base64-decoded certificates present in the header.
  • public_key_pem

    • The public key of the certificate.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pySafetyNet_Attestation-0.0.5-py3-none-any.whl (3.9 kB) Copy SHA256 hash SHA256 Wheel py3 Sep 28, 2018
pySafetyNet-Attestation-0.0.5.tar.gz (3.3 kB) Copy SHA256 hash SHA256 Source None Sep 28, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page