[GH-ISSUE #5965] [Feature request] Implement a new hubspot as social-provider #27710

Closed
opened 2026-04-17 18:53:04 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @realtebo on GitHub (Nov 13, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5965

Is this suited for github?

  • Yes, this is suited for github

Hubspot is quite a standard Oauth provider.

We can succesfully configure it using oauth plugin, but it needed customization for a function

Describe the solution you'd like

use the code from the next section to implement a new social provider for hubspot

it's quite standard, except the implementation of getUserInfo that requires to differently map the hubspot-provided data to user profile object required by your package

Describe alternatives you've considered

currently we are doing this

  • use the genericOAuth plugin
  • customize getUserInfo
genericOAuth({
      config: [
        {
          providerId: "hubspot",
          clientId: "<app client id redacted>", 
          clientSecret: "<app client secret>",
          authorizationUrl: "https://app.hubspot.com/oauth/<portal_id>/authorize",
          tokenUrl: "https://api.hubapi.com/oauth/v1/token",

          //do not use this
          // userInfoUrl: "https://api.hubapi.com/oauth/v1/access-tokens/${token}",

          // use this implementation
          async getUserInfo(tokens) {
            const response = await fetch(
              `https://api.hubapi.com/oauth/v1/access-tokens/${tokens.accessToken}`
            );
            if (!response.ok) {
              throw new Error("Failed to retrieve HubSpot user info");
            }

            const data = await response.json();

            const rawId = data.signed_access_token?.userId as string;

            const email = data.user;

            return {
              id: rawId,
              email,
              name: email,
              emailVerified: true,
            };
          },
        },
      ],
    }),

Additional context

No response

Originally created by @realtebo on GitHub (Nov 13, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5965 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Hubspot is quite a standard Oauth provider. We can succesfully configure it using oauth plugin, but it needed customization for a function ### Describe the solution you'd like use the code from the next section to implement a new social provider for hubspot it's quite standard, except the implementation of `getUserInfo` that requires to differently map the hubspot-provided data to user profile object required by your package ### Describe alternatives you've considered currently we are doing this - use the `genericOAuth` plugin - customize `getUserInfo` ``` genericOAuth({ config: [ { providerId: "hubspot", clientId: "<app client id redacted>", clientSecret: "<app client secret>", authorizationUrl: "https://app.hubspot.com/oauth/<portal_id>/authorize", tokenUrl: "https://api.hubapi.com/oauth/v1/token", //do not use this // userInfoUrl: "https://api.hubapi.com/oauth/v1/access-tokens/${token}", // use this implementation async getUserInfo(tokens) { const response = await fetch( `https://api.hubapi.com/oauth/v1/access-tokens/${tokens.accessToken}` ); if (!response.ok) { throw new Error("Failed to retrieve HubSpot user info"); } const data = await response.json(); const rawId = data.signed_access_token?.userId as string; const email = data.user; return { id: rawId, email, name: email, emailVerified: true, }; }, }, ], }), ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 18:53:04 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 13, 2025):

Hi there! Thanks for bringing up HubSpot as a social provider. It sounds like you’ve already made solid progress by using the genericOAuth plugin with a customized getUserInfo function. Your approach—fetching the user info from HubSpot’s access token endpoint and mapping the hubspot response to include id, email, and emailVerified—is in line with our strategy for social providers that require custom mapping. To move forward, please ensure the endpoint URL and response mapping match HubSpot’s current API, and consider adding robust error handling to gracefully manage any network or data issues. Is there any additional data you need to map, or any other customization you’re considering?
tag @better-auth-agent if you would like an answer from the Agent

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3528792781 --> @better-auth-agent[bot] commented on GitHub (Nov 13, 2025): Hi there! Thanks for bringing up HubSpot as a social provider. It sounds like you’ve already made solid progress by using the genericOAuth plugin with a customized getUserInfo function. Your approach—fetching the user info from HubSpot’s access token endpoint and mapping the hubspot response to include id, email, and emailVerified—is in line with our strategy for social providers that require custom mapping. To move forward, please ensure the endpoint URL and response mapping match HubSpot’s current API, and consider adding robust error handling to gracefully manage any network or data issues. Is there any additional data you need to map, or any other customization you’re considering? tag @better-auth-agent if you would like an answer from the Agent <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27710