Quickstart
Get started implementing passkeys in your software with Contribyard.
Integrating Passkey Authentication with Contribyard in Next.js (Example)
Prerequisites
Before starting, ensure you have:
- A Next.js application.
- Installed the
@github/webauthn-json
package. - Access to the Contribyard API.
Step 1: Install Required Dependencies
In your Next.js project, install the necessary npm package:
Step 2: Configure Contribyard API
Set up your environment variables for Contribyard API access by adding the following to your .env.local
file:
Replace your_contribyard_api_key
with your actual API key from Contribyard.
Step 3: Implement Registration Flow
Create a register.js
page in your Next.js pages
directory for the user registration flow.
Step 4: Create API Endpoints for the Registration Flow
Create two API routes in the pages/api/
directory to interact with Contribyard’s /v1/passkey_attestations
and /v1/passkey_attestations/{id}/verify
endpoints.
register-challenge.js
This endpoint retrieves the attestation options from Contribyard:
register.js
This endpoint verifies the attestation:
Step 5: Implement Authentication Flow
Now, let’s implement the authentication flow. Create a login.js
page for user authentication.
Step 6: Create API Endpoints for the Authentication Flow
Create two API routes to handle authentication using the /v1/passkey_assertions
and /v1/passkey_assertions/{id}/verify
endpoints.
login-challenge.js
This endpoint retrieves the assertion challenge from Contribyard:
login.js
This endpoint verifies the assertion:
Conclusion
By following this guide, you have successfully integrated Passkey authentication using Contribyard’s API with Next.js. You can now extend this with better error handling, user feedback, and production-level security features. For further customization, refer to the Contribyard API documentation.