Trimble Authentication with Leaf

18 Nov, 2021

Trimble Authentication with Leaf

Trimble Authentication with Leaf

In this post, we are going to show you how to easily go through Trimble’s authorization flow with Leaf, that is, get authorized to access your users’ Trimble data with Leaf. All endpoints can be found in our docs and Postman collection.


Did you know the quickest and simplest way to enable provider authentication is through Magic Link or Leaf Link? Leaf provides pre-built widgets (Leaf Link) and shareable URLS (Magic Link) so you can save time on building UI. Talk to us to learn more about pricing.

Summary

  • Step 0: Create a developer account with Trimble
  • Step 1: Create Application and get your credentials
  • Step 2: Get the authentication code
  • Step 3: Get your users’ Trimble tokens with Leaf
  • Step 4: Add Trimble credentials to Leaf

Keep in mind that this tutorial is a full walkthrough. Most of the steps presented will be done only once, meaning that subsequent calls will be much easier and faster.

Step 0: Create a developer account with Trimble

(if you already have a developer account in Trimble, you can skip this step)

Creating a Trimble developer account is a very simple and automatic process, you can register here.

After that, you will have created your developer account and can go to the next step of this tutorial.

Step 1: Create Application and get your credentials

At the end of this step, you want to have retrieved:

  • Your Application Name
  • Client ID
  • Client Redirect URL

You'll need to navigate to this page on the Trimble website to request API credentials for your application. More info here.

Trimble will send you the Client ID and Client Secret after the approval process.

Step 2: Get the authentication code

To get your users' tokens to access their Trimble account, your application must go through the Trimble OAuth flow. First, you need to make a POST to

With the following Body:

Note

The URL of your application must be authorized by Trimble during the application creation from Step 1. Additional slashes can cause this step to fail.

When performing this POST, you will get the user authentication URL, you can redirect your user to the Trimble authentication page using this URL.

Leaf, data infrastructure for agriculture

After performing the authentication step, your user will be required to grant access to their organizations. If this step is skipped by the user, you will not receive data from unauthorized organizations, but you will be able to ask users to manage access again via Leaf.

Leaf, data infrastructure for agriculture

After finishing the authentication process, your user will be redirected automatically to the "client_redirect_url" provided, you need to get the code returned in the link, something similar to this:

Step 3: Get your users’ Trimble tokens with Leaf

You will now get the access token and refresh token, which you can add to the Leaf as Trimble credentials.

This will be done through the link POST to:

With the following Body:

Step 4: Add Trimble credentials to Leaf

When you integrate with a provider via Leaf, you'll need to create something called a 'Leaf User', which is used to manage provider authentication and organize data for your end users. In most cases, the Leaf User will be the farmer or consultant that has access to the source data inside the machinery company’s FMIS (e.g. Trimble).

To send your credentials to Leaf, you will need your access token from Leaf, and have already created a Leaf User.

Here is how you get your access token.
Here is how you create a Leaf User.

Note: the same Leaf User can be attached to many providers, so you can query data for that Leaf User from all the providers they have data at the same time.

Now, attach your credentials to the Leaf User you created. Send a POST to:

with the following Body:

Great!

Leaf will now begin fetching your farm data from Trimble. You can now query Leaf for your standardized data.

Software developers use Leaf’s API to build and scale a wide range of products including farm optimization tools, lending products, outcome-based financing, land and input marketplaces, agronomic recommendations, traceability applications, equipment maintenance forecasting, and more.

At Leaf, we’re empowering developers working on food and farm problems. It begins with API access to field boundaries, precision agriculture data, and advanced satellite imagery.

Ready to begin?

Get API Keys and Start Building Today!

Sign up for free account

Questions? Get in touch