How it works
1
Create a Contributor
When your authenticated user accesses Elements, create a Contributor record in Pylon’s system with the user’s name and email.
2
Request authorization lease
When the user wants to use Elements, your backend requests a new authorization lease for the user’s Contributor.
3
Return lease to frontend
Your backend receives the authorization lease from Pylon and passes it to the Elements component.
4
Element loads
The Element uses the lease to securely communicate with the Pylon API.
This is a one-time setup. Once configured, all Elements in your application will use the same auth handshake.
Prerequisites
Before setting up authentication, ensure you can authenticate with the Pylon API using OAuth 2.0 Client Credentials.Implementation steps
Step 1: Create a new route
Create an endpoint on your backend (we’ll use/auth/pylon as an example). This route should:
- Return
401unless accessed by a logged-in user - Gather information about the logged-in user
- Get an authorization lease from the Pylon API
- Return the lease for use in Elements
Step 2: Gather user information
In your backend route handler, collect the following from your logged-in user:Step 3: Create or retrieve Contributor
Use the Pylon API’scontributor { createContributor } mutation to create or retrieve a Contributor record:
Step 4: Create authorization lease
Use thecontributor { createLease } mutation with the contributorId:
Example implementation
Nest.js example
src/auth/pylon.service.ts
src/auth/pylon.controller.ts
Implement logout
When a user logs out of your platform, destroy the Pylon session:Content Security Policy (CSP)
If you’re using a Content Security Policy, add these directives:{customer-id} with your customer ID and {env} with test or prod.
Next steps
With authentication configured, you can now build Elements into your app:- Loan Application Element - Start here for new applications
- Borrower Dashboard Element - For managing existing loans