AgLeader Authentication with Leaf

09 Oct, 2021

AgLeader Authentication with Leaf

AgLeader Authentication with Leaf

In this article, we will walk you through the authorization process of AgFiniti, the AgLeader platform software. We will also go through how to link AgFiniti to your Leaf users and start retrieving data.

(Clique aqui para a tradução em português)


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 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

The following 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.

Please complete this form to create your account.

Note: This account and credentials also serves as a test account for AgFiniti.

Step 1: Get your AgLeader developer credentials

Log in to your AgLeader account.

Leaf, data infrastructure for agriculture

Next, navigate to the 'Consumer Keys' tab and save the Public and Private Key for later use.

Note: Even though you're integrating with Leaf, AgLeader will require your proof of liability insurance and a one time fee before providing developer credentials.

You must configure the "Redirection URL(s)" on the application page in the AgLeader dashboard. It should include the callback URL that will receive the code after the authentication process in Step 2.

Leaf, data infrastructure for agriculture

Step 2: Get your AgLeader tokens

In this next step, we will use the /authorize URL to retrieve your Bearer Token (Access Token) and Refresh Token.

Creating the user authentication URL

This is the URL you should redirect your user to in order to get the credentials information. You need to set the parameters by replacing the {your_public_key} and the {redirect_uri} (make sure the URI is correctly registered in the allowed Redirection URLs):

If you plan to allow Prescriptions upload, you must also add the fileupload scope.

Once you add the parameters to the URL, you will redirect the user to this authentication page. This URL already has the required scopes for Leaf API integration.

Getting the Refresh Token

After the authentication process, your user will be redirected to the redirect_uri informed in the URL, and you will be able to get the code parameter that AgLeader added. This will be one of the parameters to get the token.

Leaf, data infrastructure for agriculture

Get the code parameter on your page and POST it to this other URL. You must add an "Authorization" header with basic authentication, using your publickey:privatekey encoded in base 64. For example, if the public key is "foo" and the private key is "bar", then the "Authorization" header would be "Basic Zm9vOmJhcg==".

In the response, you can get the refresh_token to be used in the next steps.

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

Your AgFiniti credentials must be linked to a Leaf User 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, the files will be retrieved, standardized, and available within a few minutes. Operation files will take several hours to complete processing.

Note: Only Machine files are supported in this integration.

TO CREATE A LEAF USER

POST to

With the following Header:

Note, more information on authentication here

ADD AGLEADER CREDENTIALS TO YOUR LEAF USER

POST to

With the following Header:

And with the following JSON as the request payload:

GET ALL FILES FROM THAT LEAF USER

GET to

With the following Header:

Note: Your developer credentials will also allow you to log in to a test AgFinity account. Please reach out to your CSM to obtain test data.

 Leaf | Data infrastructure for agriculture

Lacey Baker

Product Support Manager

Lacey Baker, Iowa native, is the Product Support Manager with Leaf Agriculture. She started her career in the health industry serving as a certified medical assistant but her love for agriculture drew her over to the agriculture industry. She has worked in IT and digital customer support with DuPont Pioneer, MapShots, Inc., and Granular where she managed support teams and implemented ticket resolution processes. Lacey is passionate about building relationships and is driven for excellence, which makes her a fantastic conduit between our customers' success and product development.

Connect with me

Ready to begin?

Get API Keys and Start Building Today!

Sign up for free account

Questions? Get in touch