Auth.js (next-auth)

Simple ID OAuth Provider Integration Guide for Auth.js

This guide explains how to integrate Simple ID as a custom OAuth 2.0 provider in your Auth.js (NextAuth.js) application.

Prerequisites

  • Node.js 16.13.0 or later

  • An Auth.js project set up in your application

  • A registered application in Simple ID with:

    • Client ID

    • Client Secret

    • Configured redirect URIs

Implementation Steps

1. Install Required Dependencies

npm install next-auth
# or
yarn add next-auth

2. Create Custom Provider Configuration

Create a new file simple-id.ts in your project's auth providers directory:

3. Configure Auth.js

Update your Auth.js configuration file ([...nextauth].ts or similar):

4. Environment Configuration

Add the following variables to your .env.local file:

5. Add Sign-in Button

Add the sign-in button to your React component:

Available Scopes

Simple ID supports the following scopes:

  • openid

  • email

  • offline_access

  • app:read

  • app:write

  • app.address:read

  • app.address:write

  • app.cryptocurrency:read

  • app.cryptocurrency:write

  • billing:read

  • invoice:read

  • product:write

Error Handling

Add error handling in your Auth.js configuration:

Security Considerations

  1. Always store sensitive credentials in environment variables

  2. Enable PKCE (Proof Key for Code Exchange) for added security

  3. Implement proper error handling and logging

  4. Use HTTPS in production

  5. Regularly rotate your client secrets

Debugging Tips

  1. Enable debug mode in Auth.js:

  1. Check the browser console and server logs for error messages

  2. Verify your redirect URIs are correctly configured in Simple ID

  3. Ensure all required scopes are properly requested

Additional Resources

Last updated

Was this helpful?