Allow to set scope for Salesforce social login #2501

Closed
opened 2026-03-13 09:59:31 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @henrikvedal on GitHub (Dec 10, 2025).

Is this suited for github?

  • Yes, this is suited for github

Today salesforce allows us to configure these scopes within the connected app but Better Auth will only use the scope openid, email, and profile. This will break very specific configuration within the connected app not allowing us to migrate from AuthJs to Better Auth.

Additionally if trying to work around with generic OAuth won't work ether as that don't support custom redirect urls.

Describe the solution you'd like

I would like Salesforce social provider to allow to set custom scopes:

export const auth = betterAuth({
    socialProviders: {
        salesforce: { 
            clientId: process.env.SALESFORCE_CLIENT_ID as string, 
            clientSecret: process.env.SALESFORCE_CLIENT_SECRET as string, 
            environment: "production", // or "sandbox".
            scope: ['full', 'api', 'refresh_token', 'offline_access']
        }, 
    },
})

Describe alternatives you've considered

Alternative solution would be to allow genericOAuthClient to set custom redirectURL to have the flexibility create custom solutions.

Additional context

No response

Originally created by @henrikvedal on GitHub (Dec 10, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Today salesforce allows us to configure these scopes within the connected app but Better Auth will only use the scope openid, email, and profile. This will break very specific configuration within the connected app not allowing us to migrate from AuthJs to Better Auth. Additionally if trying to work around with generic OAuth won't work ether as that don't support custom redirect urls. ### Describe the solution you'd like I would like Salesforce social provider to allow to set custom scopes: ``` export const auth = betterAuth({ socialProviders: { salesforce: { clientId: process.env.SALESFORCE_CLIENT_ID as string, clientSecret: process.env.SALESFORCE_CLIENT_SECRET as string, environment: "production", // or "sandbox". scope: ['full', 'api', 'refresh_token', 'offline_access'] }, }, }) ``` ### Describe alternatives you've considered Alternative solution would be to allow `genericOAuthClient` to set custom redirectURL to have the flexibility create custom solutions. ### Additional context _No response_
GiteaMirror added the social-provider label 2026-03-13 09:59:31 -05:00
Author
Owner

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

(tag @better-auth-agent if you would like an answer from the Agent)

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Dec 10, 2025): (tag @better-auth-agent if you would like an answer from the Agent) _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@Ridhim-RR commented on GitHub (Dec 10, 2025):

@better-auth-agent

@Ridhim-RR commented on GitHub (Dec 10, 2025): @better-auth-agent
Author
Owner

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

Hi there, thanks for your detailed request! Currently, our Salesforce social provider is hardcoded to use the default scopes—openid, email, and profile—which means it doesn’t allow for custom scopes like the ones you need. We’re aware that this limitation poses challenges for migrations from AuthJs and that using the generic OAuth client doesn’t fully address the issue due to its lack of support for custom redirect URLs [1].

We’re actively discussing enhancements in this area, and your input helps us prioritize this feature. Could you share any additional details about your specific configuration requirements or any other custom behaviors you need? It would be great to understand your use case better.

tag @better-auth-agent if you would like an answer from the Agent.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Dec 10, 2025): Hi there, thanks for your detailed request! Currently, our Salesforce social provider is hardcoded to use the default scopes—openid, email, and profile—which means it doesn’t allow for custom scopes like the ones you need. We’re aware that this limitation poses challenges for migrations from AuthJs and that using the generic OAuth client doesn’t fully address the issue due to its lack of support for custom redirect URLs [[1]](https://github.com/better-auth/better-auth/issues/1183). We’re actively discussing enhancements in this area, and your input helps us prioritize this feature. Could you share any additional details about your specific configuration requirements or any other custom behaviors you need? It would be great to understand your use case better. 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/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@Ridhim-RR commented on GitHub (Dec 10, 2025):

Looking into it

@Ridhim-RR commented on GitHub (Dec 10, 2025): Looking into it
Author
Owner

@henrikvedal commented on GitHub (Dec 10, 2025):

I did some digging in the code and found that disableDefaultScope and scope supported, but it's not mentioned in the docs:
https://www.better-auth.com/docs/authentication/salesforce#configuration-options

@henrikvedal commented on GitHub (Dec 10, 2025): I did some digging in the code and found that `disableDefaultScope` and `scope` supported, but it's not mentioned in the docs: https://www.better-auth.com/docs/authentication/salesforce#configuration-options
Author
Owner

@Ridhim-RR commented on GitHub (Dec 10, 2025):

Yes , custom scopes are handled . This piece of code make sure to add the custom roles if provided.

const _scopes = options.disableDefaultScope
? []
: ["openid", "email", "profile"];
if (options.scope) _scopes.push(...options.scope);
if (scopes) _scopes.push(...scopes);

@Ridhim-RR commented on GitHub (Dec 10, 2025): Yes , custom scopes are handled . This piece of code make sure to add the custom roles if provided. const _scopes = options.disableDefaultScope ? [] : ["openid", "email", "profile"]; if (options.scope) _scopes.push(...options.scope); if (scopes) _scopes.push(...scopes);
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2501