GithubHelp home page GithubHelp logo

wukamm / applepassgenerator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twopointone/applepassgenerator

0.0 0.0 0.0 47 KB

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

Home Page: https://primedigitalglobal.github.io/applepassgenerator/

License: MIT License

Python 100.00%

applepassgenerator's Introduction

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

  • 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.

applepassgenerator's People

Contributors

vaibhav015 avatar hardik-pdgt avatar vaibhav-pdgt avatar wukamm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.