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.
- 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, just register with this link.
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
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 data, your application must go through Trimble OAuth flow. First, you need to make a POST to
With the following Body:
When performing this
POST, you will have the return of a URL. Open this link and you will be taken to the Trimble API if you are not already logged in. Otherwise, you will be automatically redirected to the Leaf blog home page. At this point, it is necessary to save the code contained in the page 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
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.
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
with the following Body:
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.Get a demo