Tutorial

AgLeader authentication with Leaf

How to connect with AgLeader via Leaf's API



Leaf’s API is the easiest way to build with farm 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.

Here is a link to Leaf’s website and docs.

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.

In this post, we will show you how easily we can follow the authorization routine on AgFiniti, which is the AgLeader platform software where we will be retrieving data from, and get the necessary permissions to access your farm data with Leaf.

Summary

  • Step 0: Create your AgFiniti account;
  • Step 1: Get your AgLeader developer credentials;
  • Step 2: Get your AgLeader tokens;
  • Step 3: Create a Leaf User with AgLeader credentials on Leaf;

These steps are a full walkthrough. Once you follow the necessary steps you will not need to repeat them for subsequent calls.

Step 0: Create a developer account with AgLeader  

(This step can be skipped if you already have an account in AgLeader, otherwise, you should follow the instructions below).

To create a new account on the AgFiniti just click on this link.

After you have created your developer account, you can follow the next step of this tutorial.

Step 1: Get your AgLeader developer credentials

First of all, make sure to log in to your AgLeader account, with the following URL https://www.agfiniti.com/Home/Welcome,
and click in the white forward arrow inside an orange circle.

Next, access the “Consumer Keys” tab and save the Public and Private Key. We will be using both later. 

You can also confirm all the operation data related to your account by accessing the Mappable Data tab from the Resources icon in the profile scroll list. We will present a sample of one of these files processed via Leaf later.

Step 2: Get your AgLeader tokens

In this next step, we are going to use the /authorize URL to retrieve the Bearer Token (Access Token) and the Refresh Token. For that, we are going to set parameters that will allow us to configure the type of permissions on our account.

Here is an example of how it should look:

https://www.agfiniti.com/api/oauth2/authorize?response_type=code&client_id= _your_Public_ Key_ &scope=openid%20profile%20email%20filedownload

After filling the URL properly with your Public Key, you will be redirected to a page where will be able to retrieve your Access Token and Refresh Token.

Step 3: Create a Leaf User with AgLeader credentials on Leaf

Leaf’s API must then be initiated with AgLeader credentials in order to access the data from your user’s AgFiniti account. After creating a Leaf User and adding these credentials to the Leaf User, their files will be standardized and available for retrieval in a few minutes.  

1. Create a Leaf User

POST to

https://api.withleaf.io/services/usermanagement/api/users/

with the following Header: Authorization: Bearer

note: here’s how to get your Leaf token

2. Add AgLeader Credentials to your Leaf User

POST to

https://api.withleaf.io/services/usermanagement/api/users//ag-leader-credentials

with the following Header: Authorization: Bearer

and with the following JSON as the request payload

3. Get all files from that Leaf User

GET to

https://api.withleaf.io/services/operations/api/files?leafUserId=&provider=AgLeader

with the following Header: Authorization: Bearer

Good Job!

 

Here we can see next, a sample of a Leaf file processed response.

Leaf will pull all the files from your user’s AgFiniti account and in a matter of minutes, you will be able to retrieve your data. 

See you next time!

Similar posts

Stay in the loop with all of Leaf's future insights, technical updates and latest case studies.

Subscribe to receive our monthly newsletter and newest blog posts with industry leading insights, company updates and more.