[GH-ISSUE #2000] Add 42 provider #8997

Closed
opened 2026-04-13 04:15:09 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @awbx on GitHub (Mar 25, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2000

Is this suited for github?

  • Yes, this is suited for github

The current better-auth package lacks support for 42 (École 42) authentication, which prevents applications from offering this sign-in option to users. Many educational tech platforms and developer tools need to support authentication with 42 accounts, as it's a prominent coding school with a large student and alumni network.

Describe the solution you'd like

I'd like better-auth to add support for 42 (École 42) as an authentication provider. The implementation should follow the existing provider pattern with:

  • OAuth2 integration with 42's API
  • Configuration options for clientId and clientSecret
  • Standard callback URL handling
  • Proper parsing of user profile data from 42's API responses
  • Supporting documentation and TypeScript type definitions

Describe alternatives you've considered

  1. Creating a custom authentication handler outside the better-auth system, but this would lack integration with the rest of the auth flow
  2. Using a generic OAuth provider configuration and adapting it manually for 42's endpoints, but this requires more work from end users and lacks official support
  3. Forking better-auth to add this feature, but this would create maintenance overhead and diverge from the main package updates

Additional context

42 is a global network of coding schools with a unique educational model, and many applications specifically targeting developers and students would benefit from this integration. The authentication uses standard OAuth2 flow, similar to existing providers. I've already created an SVG icon for use with the provider that matches the standard format used in the project.

Originally created by @awbx on GitHub (Mar 25, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2000 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. The current better-auth package lacks support for 42 (École 42) authentication, which prevents applications from offering this sign-in option to users. Many educational tech platforms and developer tools need to support authentication with 42 accounts, as it's a prominent coding school with a large student and alumni network. ### Describe the solution you'd like I'd like better-auth to add support for 42 (École 42) as an authentication provider. The implementation should follow the existing provider pattern with: - OAuth2 integration with 42's API - Configuration options for clientId and clientSecret - Standard callback URL handling - Proper parsing of user profile data from 42's API responses - Supporting documentation and TypeScript type definitions ### Describe alternatives you've considered 1. Creating a custom authentication handler outside the better-auth system, but this would lack integration with the rest of the auth flow 2. Using a generic OAuth provider configuration and adapting it manually for 42's endpoints, but this requires more work from end users and lacks official support 3. Forking better-auth to add this feature, but this would create maintenance overhead and diverge from the main package updates ### Additional context 42 is a global network of coding schools with a unique educational model, and many applications specifically targeting developers and students would benefit from this integration. The authentication uses standard OAuth2 flow, similar to existing providers. I've already created an SVG icon for use with the provider that matches the standard format used in the project.
GiteaMirror added the locked label 2026-04-13 04:15:09 -05:00
Author
Owner

@alexandre-hallaine commented on GitHub (May 27, 2025):

I think that's the best way currently :/

import { betterAuth } from "better-auth";
import { genericOAuth } from "better-auth/plugins";

export const auth = betterAuth({
  plugins: [
    genericOAuth({
      config: [
        {
          providerId: "fortytwo",
          clientId: process.env.FORTYTWO_CLIENT_ID as string,
          clientSecret: process.env.FORTYTWO_CLIENT_SECRET as string,
          authorizationUrl: "https://api.intra.42.fr/oauth/authorize",
          tokenUrl: "https://api.intra.42.fr/oauth/token",
          userInfoUrl: "https://api.intra.42.fr/v2/me",
          scopes: ["public"],
        },
      ],
    }),
  ],
});
<!-- gh-comment-id:2914223407 --> @alexandre-hallaine commented on GitHub (May 27, 2025): I think that's the best way currently :/ ```ts import { betterAuth } from "better-auth"; import { genericOAuth } from "better-auth/plugins"; export const auth = betterAuth({ plugins: [ genericOAuth({ config: [ { providerId: "fortytwo", clientId: process.env.FORTYTWO_CLIENT_ID as string, clientSecret: process.env.FORTYTWO_CLIENT_SECRET as string, authorizationUrl: "https://api.intra.42.fr/oauth/authorize", tokenUrl: "https://api.intra.42.fr/oauth/token", userInfoUrl: "https://api.intra.42.fr/v2/me", scopes: ["public"], }, ], }), ], }); ```
Author
Owner

@dosubot[bot] commented on GitHub (Aug 26, 2025):

Hi, @awbx. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary

  • You requested adding 42 (École 42) as an OAuth2 provider with clientId/clientSecret config, callback, and user profile parsing.
  • The maintainer provided a code example using the existing genericOAuth plugin to integrate 42's OAuth endpoints.
  • This solution follows the current provider pattern and enables sign-in via 42 accounts.
  • You and another user expressed positive feedback on this approach.
  • The issue was resolved with this integration example.

Next Steps

  • Please confirm if this solution still works with the latest version of better-auth or if you need further assistance.
  • If no further comments are made, I will automatically close this issue in 7 days.

Thanks for your understanding and contribution!

<!-- gh-comment-id:3224826754 --> @dosubot[bot] commented on GitHub (Aug 26, 2025): Hi, @awbx. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary** - You requested adding 42 (École 42) as an OAuth2 provider with clientId/clientSecret config, callback, and user profile parsing. - The maintainer provided a code example using the existing genericOAuth plugin to integrate 42's OAuth endpoints. - This solution follows the current provider pattern and enables sign-in via 42 accounts. - You and another user expressed positive feedback on this approach. - The issue was resolved with this integration example. **Next Steps** - Please confirm if this solution still works with the latest version of better-auth or if you need further assistance. - If no further comments are made, I will automatically close this issue in 7 days. Thanks for your understanding and contribution!
Author
Owner

@alexandre-hallaine commented on GitHub (Sep 3, 2025):

no!

<!-- gh-comment-id:3248888375 --> @alexandre-hallaine commented on GitHub (Sep 3, 2025): no!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8997