Perkville → external reward provider customer handoff
Goal
Let a customer already authenticated in a partner app ("App A") open an external reward provider's platform as the correct customer without another login. Perkville supplies an encrypted identity token. The provider validates it, establishes the customer session, and opens the appropriate storefront.
The token identifies the customer and business. Customers choose rewards in the provider's platform, and redemptions continue through the existing authorization and eligibility checks.
Who implements each part
The partner app and the external reward provider may be operated by different companies.
Partner app ("App A"): Displays rewards, requests a fresh SSO launch URL from its backend when the customer selects an external reward (step 2 below), and opens the returned URL. It uses its Perkville admin API credentials for the API request.
External reward provider: Receives the customer on its platform, validates and decrypts the token, and establishes the customer session. Only the external reward provider needs to complete the secure encryption key exchange with Perkville.
Perkville: Checks authorization and generates the encrypted token and SSO launch URL.
App A does not need the provider's shared encryption key and does not decrypt the token. Its Perkville API credentials are separate from the encryption key exchanged between Perkville and the provider.
End-to-end flow
App A displays rewards using Perkville's API. It may cache the ordinary reward listing, including the existing external reward URL.
The customer taps an external reward. App A's backend requests a fresh SSO link from Perkville for its authenticated customer and the selected external reward entry. App A keeps its admin API credentials on its backend.
To request a link, please follow the instructions laid out in the Redeeming View API.
Perkville checks authorization for the API client, business admin, customer, and visible external reward. It returns a separate, two-minute SSO launch URL. The configured reward URL remains unchanged.
App A opens the launch URL, for example:
https://sso.provider.example/launch?metric=<encrypted-token>The provider validates the token and destination, consumes the token once, and creates a session for the identified customer. It then directs the customer to the destination storefront, handling any required cross-domain session transfer.
App A fetches a new link on each click to ensure a fresh token is generated. The provider does not need to call Perkville to decrypt the token; it uses the shared encryption key provisioned during setup. No pending session or cookie shared with App A is required.
What Perkville sends
The `metric` parameter contains five dot-separated components:
v1.<key_id>.<nonce>.<ciphertext>.<tag>
Item
Contract
Encryption
AES-256-GCM with a 32-byte shared key
Nonce
12 fresh random bytes per token
Authentication tag
16 bytes
Authenticated header / AAD
Exact ASCII bytes of v1.<key_id>
Binary encoding
Nonce, ciphertext, and tag each use unpadded Base64url
Plaintext
UTF-8 JSON
Lifetime
120 seconds from issuance
This is a custom AES-GCM envelope, not a JWT. GCM provides both encryption and tamper detection. The provider must verify the authentication tag before using the plaintext.
Illustrative decrypted payload (example timestamps are not live credentials):
user_idandbusiness_idare positive integer Perkville IDs.iatandexpare integerUnixtimestamps in UTC.iatis the issued at time.expis the expiration time.
token_iduniquely identifies this handoff: 16 random bytes encoded as Base64url.destination_urlis the original configured reward URL, including its path, query parameters, and fragment if present.
Provider validation and session handling
The provider completes these checks before signing the customer in:
Verify the token: Decrypt and authenticate it with the dedicated integration key using the contract above. Validate the required payload fields and their types.
Check the time: Enforce the two-minute lifetime and reject expired or future-dated tokens outside the agreed clock tolerance (proposed: 30 seconds).
Confirm the destination: Resolve the customer and confirm the HTTPS storefront is managed by the provider and authorized for that business.
Enforce single use: Atomically record token_id within the configured provider and environment across servers until expiry plus tolerance. Reject duplicates or unavailable replay checks.
Sign in and redirect: Establish a secure session and open the storefront without forwarding the original token. The provider handles session transfer for custom domains.
Treat launch links as credentials: exclude them from logs and analytics, and use Cache-Control: no-store and Referrer-Policy: no-referrer. If validation fails, ask the customer to return to the app for a fresh link.
Implementation setup and secure key exchange
The external reward provider should contact api@perkville.com for implementation details and to arrange the secure encryption key exchange with Perkville. If the partner app is operated by a separate company, that app team does not need to participate in the encryption key exchange; it implements the app-side flow above, including the fresh SSO link request in step 2.
For coordination, include the app team and the external reward provider in the implementation discussion with api@perkville.com so each team understands its responsibilities.
Last updated
Was this helpful?

