Skip to main content

Python package to create passes compatible with Apple Wallet.

Project description

Apple Pass Generator

Python library to generate passes i.e (.pkpass) files compatible with Apple Wallet (former Passbook).

Table of Contents

💾 Installation

To easily install or upgrade to the latest release, use pip.

$ pip install applepassgenerator

🍎 Apple docs

From now on, some stuff is much better explained on the Apple docs, so when in doubt just check (if you haven't done so) the following documents:

📝 Configuration

To start using the lib, some Apple files are needed, as well as some action in order to convert them to more friendly formats:

  • Get Pass Type ID

    • Go to the Apple Developer page ➵ Identifiers ➵ Pass Type IDs.
    • Next, you need to create a pass type ID. This is similar to the bundle ID for apps. It will uniquely identify a specific kind of pass. It should be of the form of a reverse-domain name style string (i.e., pass.com.example.appname).
  • Generate the necessary certificate

    • After creating the pass type ID, click on Edit and follow the instructions to create a new Certificate.

    • Once the process is finished, the pass certificate can be downloaded. That's not it though, the certificate is downloaded as .cer file, which need to be converted to .p12 in order to work. If you are using a Mac you can import it into Keychain Access and export it as .p12from there.

    • if now you have certificate.p12 file follow the steps below to convert it to certifictate.pem

      $ openssl pkcs12 -in certificate.p12 -clcerts -nokeys -out certificate.pem
      
  • Generate the key.pem

    >$ openssl pkcs12 -in certificate.p12 -nocerts -out private.key
    

    Note: While generating this private.key file you will be asked for a PEM pass phrase which will be used as the CERTIFICATE_PASSWORD attribute throughout the Package.

  • Getting WWDR Certificate

    • If you have made iOS development, you probably have already the Apple Worldwide Developer Relations Intermediate Certificate in your Mac’s keychain.
    • If not, it can be downloaded from the Apple Website (on .cer format). This one needs to be exported as .pem, It can be exported from KeyChain into a .pem (e.g. wwdr.pem).

🚀 Usage

from applepassgenerator import ApplePassGeneratorClient
from applepassgenerator.models import EventTicket

card_info = EventTicket()
card_info.add_primary_field('name', 'Tony Stark', 'Name')
card_info.add_secondary_field('loc', 'USA', 'Country')

team_identifier = "1234ABCDEF"
pass_type_identifier = "pass.com.project.example"
organization_name = "Primedigital Global"

applepassgenerator_client = ApplePassGeneratorClient(team_identifier, pass_type_identifier, organization_name)
apple_pass = applepassgenerator_client.get_pass(card_info)

# Add logo/icon/strip image to file
apple_pass.add_file("logo.png", open("<path>/logo.png", "rb"))
apple_pass.add_file("icon.png", open("<path>/icon.png", "rb"))

CERTIFICATE_PATH = "<path-to-file>/certificate.pem"
PASSWORD_KEY = "<path-to-file>/password.key"
WWDR_CERTIFICATE_PATH = "<path-to-file>/wwdr.pem"
CERTIFICATE_PASSWORD = "<password>"
OUTPUT_PASS_NAME = "mypass.pkpass"

apple_pass.create(CERTIFICATE_PATH, PASSWORD_KEY, WWDR_CERTIFICATE_PATH, CERTIFICATE_PASSWORD, OUTPUT_PASS_NAME)

Code of Conduct

In order to foster a kind, inclusive, and harassment-free community, we have a code of conduct, which can be found here. We ask you to treat everyone as a smart human programmer that shares an interest in Python and Apple Pass Generator with you.

Project details


Download files

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

Source Distribution

applepassgenerator_reloaded-0.0.3.tar.gz (33.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

applepassgenerator_reloaded-0.0.3-py3-none-any.whl (37.6 kB view details)

Uploaded Python 3

File details

Details for the file applepassgenerator_reloaded-0.0.3.tar.gz.

File metadata

  • Download URL: applepassgenerator_reloaded-0.0.3.tar.gz
  • Upload date:
  • Size: 33.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for applepassgenerator_reloaded-0.0.3.tar.gz
Algorithm Hash digest
SHA256 8bedb449f83f92da66ff1f0a32937f77a51e80bd385c921f74e9c587c76d2a3f
MD5 563c221b3bbb567060bb15f0888eaed0
BLAKE2b-256 34a23bedee49507f1bf81dcea37e5a045bfd9eaba2389ed4ce42dcf3af4eb927

See more details on using hashes here.

File details

Details for the file applepassgenerator_reloaded-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: applepassgenerator_reloaded-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 37.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for applepassgenerator_reloaded-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e44b1aa2ae7aa6e515da7c51eca0fb506520d2f952dbd275181556b55bf1a3b6
MD5 dd9ad5a4d771121b2f82f84c0684088e
BLAKE2b-256 3bd904dcb6658cd9911533bd6bd3a956bd40d95aea6d62ddebe2e49ea4e97129

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page