Skip to content
Back to catalog
Tradeshift

OAuth with Tradeshift

Authenticate users with an existing Tradeshift account

Tradeshift is a business commerce network where buyers and suppliers exchange e-invoices, purchase orders, and payments. Developers build apps for companies on the Tradeshift network, and Tradeshift accounts can sign users in to those apps over OAuth 2.0.

How does the integration work?

You can use the Tradeshift 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 procurement and invoicing tools for companies that already trade on Tradeshift.

Appwrite requests the openid and offline scopes and reads the user's ID, name, and email address from Tradeshift's API. Tradeshift doesn't report whether the email address is verified, so Appwrite stores it as unverified. If another user in your project already has the same address, Appwrite redirects to your failure URL instead of signing in to that account. To connect Tradeshift to an existing account, have the user sign in first and then start createOAuth2Session from the browser, which links Tradeshift as a new identity.

Appwrite has two Tradeshift providers. Tradeshift signs users in through Tradeshift's production API at api.tradeshift.com, and Tradeshift Sandbox uses the sandbox API at api-sandbox.tradeshift.com, so you can test with sandbox accounts first.

How to implement

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

Step 1: Create a Tradeshift app with OAuth2 credentials

First, sign in to Tradeshift, or to the Tradeshift sandbox while you test, and create an app with Tradeshift's developer tools. Follow the Tradeshift Developer Center for the current steps. Configure the app's OAuth2 settings and save its OAuth2 Client ID and OAuth2 Client Secret. You will set the app's redirect URI in the next step.

Step 2: Add the Tradeshift 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 Tradeshift under the OAuth2 Providers section. For a sandbox app, click Tradeshift Sandbox instead.

Enter the OAuth2 Client ID and OAuth2 Client Secret you saved from Tradeshift, 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/tradeshift/<PROJECT_ID>

The URI starts with the API endpoint your app uses, so on self-hosted Appwrite it starts with your own domain. The Tradeshift Sandbox provider has its own URI, ending in /tradeshiftBox/<PROJECT_ID>. Always copy the exact value from the Console. Back in Tradeshift, set this URI as your app's OAuth2 redirect URI.

When Appwrite runs on localhost, it sends Tradeshift 127.0.0.1 in the redirect URI instead, so register the URI with 127.0.0.1 in that case.

Step 3: Test the provider

Follow the OAuth 2 login flow to test your provider. Pass OAuthProvider.Tradeshift as the provider, or OAuthProvider.TradeshiftBox for a sandbox app, 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 Tradeshift and Appwrite Auth

If you would like to learn more about Tradeshift 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.