Skip to content

Instantly share code, notes, and snippets.

@erunyon
Last active February 7, 2022 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erunyon/dd62cf77af9c70d6822e9775ce19be9f to your computer and use it in GitHub Desktop.
Save erunyon/dd62cf77af9c70d6822e9775ce19be9f to your computer and use it in GitHub Desktop.
Passkit Authentication
require "json"
require "httparty"
require 'jwt'
require 'pp'
KEY = "YOUR_KEY"
SECRET = "YOUR_SECRET"
PROG = "THE_PROGRAM_ID"
class Passkit
include HTTParty
format :json
end
# Generate the token
payload = { uid: KEY, iat: Time.now.to_i, exp: Time.now.to_i + 6000, web: true }
token = JWT.encode(payload, SECRET, 'HS256')
# Get Program Information
json = Passkit.get("https://api.pub1.passkit.io/members/program/#{PROG}",
:body => {},
:headers => {
'Content-Type' => 'application/json',
'Authorization' => token
}
)
pp json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment