Last active
February 7, 2022 15:32
-
-
Save erunyon/dd62cf77af9c70d6822e9775ce19be9f to your computer and use it in GitHub Desktop.
Passkit Authentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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