Skip to content

Instantly share code, notes, and snippets.

@erunyon
Last active Feb 7, 2022
Embed
What would you like to do?
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