Skip to content
Back to catalog
Salesforce

OAuth with Salesforce

Authenticate users with an existing Salesforce account

Salesforce is a customer relationship management (CRM) platform that companies use for sales, service, marketing, and custom business apps. Every Salesforce user belongs to an org, and Salesforce acts as an OAuth 2.0 and OpenID Connect provider for those users, so apps built for Salesforce customers can sign them in with the accounts they already use at work.

How does the integration work?

You can use the Salesforce OAuth adapter in Appwrite Auth for user authentication and management. This can be convenient for users because they can start using your app without creating a new account, and it suits companion apps, dashboards, and partner tools for teams that run on Salesforce.

Appwrite uses the OAuth 2.0 web server flow through login.salesforce.com and requests the openid and profile scopes. It reads the user's name and email address from Salesforce's user info endpoint and marks the email as verified only when Salesforce reports it as verified. Salesforce also shares the user's profile photo, which Appwrite uses for user photos in Appwrite Avatars.

Because sign-in goes through login.salesforce.com, it works for users of production and Developer Edition orgs. Users of Salesforce sandbox orgs, which sign in through test.salesforce.com, can't use this provider.

How to implement

To implement the Salesforce OAuth adapter in Appwrite Auth, there are several steps you must complete:

Step 1: Create a Salesforce app with OAuth enabled

First, sign in to Salesforce and open Setup. Create an app that can use OAuth, such as an external client app or a connected app, and enable its OAuth settings. Select OAuth scopes that include openid and profile, which Appwrite requests. For the callback URL, temporarily add https://temporary-endpoint.com/. You will replace it with the URI from Appwrite in the next step.

After you save the app, open its OAuth details and save the Consumer Key and Consumer Secret for later use. Salesforce may ask you to verify your identity before it shows them.

Step 2: Add the Salesforce OAuth adapter to your Appwrite project

For this step, you must create an account on Appwrite Cloud or self-host Appwrite if you haven't already. In your Appwrite project, head over to the Auth page, open the Settings tab, and click Salesforce under the OAuth2 Providers section.

Enter the Consumer Key and Consumer Secret you saved from Salesforce. Optionally, set Prompt to login to ask the user to sign in again, or consent to ask for consent again. Turn the provider on and click Update.

Copy the Redirect URI shown in the provider settings. It follows this format:

Plain text
https://<REGION>.cloud.appwrite.io/v1/account/sessions/oauth2/callback/salesforce/<PROJECT_ID>

The URI starts with the API endpoint your app uses, so on self-hosted Appwrite it starts with your own domain. Always copy the exact value from the Console. Back in Salesforce, replace the temporary callback URL in your app's OAuth settings with this URI and save.

Step 3: Test the provider

Follow the OAuth 2 login flow to test your provider. Pass OAuthProvider.Salesforce as the provider when you call createOAuth2Session from a client app or createOAuth2Token from a server. Add your app's domain as a platform in your Appwrite project so Appwrite accepts your success and failure URLs.

Read more about Salesforce and Appwrite Auth

If you would like to learn more about Salesforce and Appwrite Auth, we have some resources that you should visit:

Technology Partner Program

Building on Appwrite?

Teams and developers who ship integrations, tools, or services on Appwrite can join our partner program for verified catalog placement, co-marketing, training, and engineering support.