<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by G. Bueno on Medium]]></title>
        <description><![CDATA[Stories by G. Bueno on Medium]]></description>
        <link>https://medium.com/@gmbueno?source=rss-bc6ed4ddcfe3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*daWbFFi1576P77y6398H7w.jpeg</url>
            <title>Stories by G. Bueno on Medium</title>
            <link>https://medium.com/@gmbueno?source=rss-bc6ed4ddcfe3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 15:06:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gmbueno/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to update your John Deere API Integration]]></title>
            <link>https://medium.com/leaf-agriculture/how-to-update-your-john-deere-api-integration-7c6ab7b450b3?source=rss-bc6ed4ddcfe3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c6ab7b450b3</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[api-integration]]></category>
            <category><![CDATA[agtech]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[G. Bueno]]></dc:creator>
            <pubDate>Mon, 01 Feb 2021 21:22:27 GMT</pubDate>
            <atom:updated>2021-02-01T21:43:16.494Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WlpY6kAp8iPdY3Oh.png" /><figcaption><a href="https://leaf-agriculture.github.io/docs/docs/index.html">the best way to build with farm data</a></figcaption></figure><p>John Deere Operation Center is adding a new organization level access layer and deprecating older authentication options on March 10th, 2021.</p><p>To ensure your integration continues to function, your application must follow three simple steps, listed below:<br><em>1) Update to OAuth2: <br>2) Update authentication links <br>3) A</em>llow organization access</p><h3><em>1) Update to OAuth2:</em></h3><p>If your application is already integrated with John Deere and your tokens begin with “accessToken” and “refreshToken” then you are already using OAuth2 tokens and can move to step 3.</p><p>If your application is not integrated with John Deere yet or is using OAuth1, you will need to generate new OAuth2 tokens. <a href="https://medium.com/leaf-agriculture/john-deere-authentication-with-leaf-7691b155b744">Here is a tutorial on how to do this.</a></p><h3>2) Update authentication links</h3><p>Once you have your OAuth2 tokens, you should update your existing user tokens and authentication links in your App.</p><h3><em>3) Obtain</em> organization access</h3><p>(Only after March 10th, 2021)</p><p>From March 10th, 2021, John Deere will be requiring that your users explicitly select which organizations they want to allow you access. This is a separate step, not being part of the OAuth2 flow.</p><p>With John Deere’s recent changes, your users will now also need to set their organization permissions within John Deere Operation Center to give access to your App.</p><p><strong>a) If you want to make these changes before March 10th, 2021 (recommended): Notify John Deere Dev Support</strong></p><p>Notify John Deere API Dev Support that you’re ready to begin. Go to</p><blockquote><a href="https://developer.deere.com/">https://developer.deere.com/</a></blockquote><p>Click &quot;Contact Us&quot; button in the lower right-hand corner and use the Connections Testing form to let John Deere know you are starting your Connections work so they will whitelist your application in sandbox and enable access for your test organizations.</p><p><strong>b) Obtain organization access</strong></p><p>The user is in control of which organization’s data your application can access.<br>After you get a user token, redirect the user to John Deere&#39;s system and in the same URI provide a redirect back to your application. The redirect URI that is provided must match one of the Callback URLs (Redirect URI) listed in your application profile.</p><blockquote>Example URI: <br><a href="https://connections.deere.com/connections/%7BclientId%7D/select-organizations?redirect_uri={redirectUri">https://connections.deere.com/connections/{clientId}/select-organizations?redirect_uri={redirectUri</a>}</blockquote><p>Then, the user selects the organization(s) to which you can have access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5whM3GCp5oGaqnw8.png" /><figcaption>image directly <a href="https://developer-portal.deere.com/#/start-developing/help/get-started/help-connections">from John Deere</a></figcaption></figure><p>Once the organization selection is complete, the user is re-directed back to your software application.</p><p>Now that your users gave your application access to their organizations, you’re all set!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c6ab7b450b3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/leaf-agriculture/how-to-update-your-john-deere-api-integration-7c6ab7b450b3">How to update your John Deere API Integration</a> was originally published in <a href="https://medium.com/leaf-agriculture">Leaf blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Como acessar dados autorizados dos seus usuários na John Deere]]></title>
            <link>https://medium.com/leaf-api/como-acessar-dados-autorizados-dos-seus-usu%C3%A1rios-na-john-deere-c2ef332a6037?source=rss-bc6ed4ddcfe3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2ef332a6037</guid>
            <category><![CDATA[api-integration]]></category>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[agtech]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[agriculture-technology]]></category>
            <dc:creator><![CDATA[G. Bueno]]></dc:creator>
            <pubDate>Mon, 28 Sep 2020 22:57:03 GMT</pubDate>
            <atom:updated>2020-10-19T18:50:50.639Z</atom:updated>
            <content:encoded><![CDATA[<p>Se sua aplicação quer acessar dados (autorizados) de seus usuários na John Deere, você está no post certo!</p><p>Nesta postagem vamos mostrar duas coisas:</p><ul><li>como passar facilmente pelo fluxo (OAuth2) de autorização da John Deere, ou seja, obter autorização dos seus usuários para acessar os dados na John Deere.</li><li>como acessar os dados autorizados dos seus usuários na John Deere.</li></ul><p>Os dados que vamos buscar incluem, por exemplo, os campos (limites geométricos de um talhão) e dados de operação do campo. Como esses dados vêm da John Deere em um formato difícil de lidar e cru, vamos utilizar a <a href="https://leaf-agriculture.github.io/docs/docs/index.html">Leaf</a> para pegar os dados já processados, em uma resposta padrão e com vantagens como mapas dessas operações, o que foi plantado/aplicado/colhido, a área e a data que essa operação ocorreu, umidade do grão, elevação do campo o que permite o monitoramento personalizado, acompanhado todo o ciclo operacional agrícola da sua área interesse e muito mais!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*frjST_-6NWUeyFanMgApeA.png" /><figcaption>Exemplo de imagem gerada para o mapa de colheita</figcaption></figure><p>Vamos lá!</p><h3>Resumo</h3><ul><li><strong>Passo 0: </strong>Criar uma conta de desenvolvedor na John Deere</li><li><strong>Passo 1:</strong> Pegar suas credenciais de desenvolvedor na John Deere</li><li><strong>Passo 2:</strong> Autorizar com o usuário e pegar os tokens de acesso</li><li><strong>Passo 3: </strong>Eureka!<strong> </strong>Acessar os dados (autorizados) dos usuários</li></ul><p>Este tutorial é um passo a passo completo. Os passos 0 e 1 só precisam ser realizados uma vez, já que não são diretamente relacionados com a autorização (mas necessários). Isso significa que autorizar com os usuários será muito mais fácil e rápido, apenas repetindo o passo 2. Se você já tem os tokens de acesso às contas de seus usuários, pule diretamente para o passo 3.</p><h3>Passo 0: Criar conta de desenvolvedor na John Deere</h3><p>O intuito de criar uma conta de desenvolvedor na John Deere é de conseguir credenciais que identificam a sua aplicação ao acessar a API da John Deere.</p><p>Atenção: A conta de desenvolvedor na John Deere é diferente de uma conta de usuário. Embora seja possível utilizar a mesma conta, os propósitos são diferentes. A conta de desenvolvedor tem como propósito acessar a API da John Deere para pegar os dados (autorizados) de contas de usuários, enquando essas visam gerenciamento de fazendas (Operations Center).</p><p>Se você já tem sua conta de desenvolvedor na John Deere ou deseja utilizar uma conta de usuário, pode seguir para o próximo passo.</p><p>Se deseja criar sua conta agora, basta se registrar <a href="https://myjohndeere.deere.com/wps/portal/myjd/registration">nesse link</a>.</p><h3>Passo 1: Pegar as credenciais de desenvolvedor na JD</h3><p>No final desse passo, você deve ter pego seu App ID e seu Shared Secret</p><p>Primeiro logue na sua conta (de desenvolvedor) da John Deere <a href="https://developer.deere.com/">neste link</a> ao clicar em <strong>LOG IN </strong>no canto superior direito.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dIFaXG4TaExXRp7RU5L9ww.png" /></figure><p>Após entrar na sua conta, clique no ícone de perfil e em Applications, como mostrado na figura abaixo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dRujBRjen9195ZEbJ9bRRg.png" /></figure><p>Neste momento, você provavelmente não tem nenhuma aplicação criada, então basta clicar em “Add Application”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lkIFaz2kxF8cs7bV_e7r7Q.png" /></figure><p>Em seguida, clique em “See More” e você verá o seu <strong>App ID</strong> e <strong>Shared Secret.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nxneH3_VALHoIvrHVaX8Sw.png" /></figure><p>Para finalizar, deve ser incluída, no seu app da John Deere, a URL de redirecionamento da sua aplicação, que seu usuário será redirecionado depois de autorizar. É importante que essa URL seja de sua aplicação, pois um código será enviado à ela pela John Deere toda vez que um novo usuário se autorizar e esse código será necessário nos próximos passos.</p><p>Para adicionar a URL ao seu app da John Deere, clique em OAuth Profile, como mostrado na imagem abaixo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tfj7R9j6qIDjHb9k3bwudg.png" /></figure><p>Em seguida, desça até o final da página e adicione a sua URL de redirecionamento como mostrado a seguir:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DXxC-lva8MgzHqpTPq9K-g.png" /></figure><p>obs: os campos “Description” e “Legal Disclaimer” não podem ser nulos, então sinta-se livre para adicionar uma breve descrição do seu app.</p><p>Perfeito! Seu app está pronto! A John Deere leva em torno de dois dias para ativar o seu app e você poder utilizá-lo para fazer chamadas à API.</p><p>Agora com o seu App ID e Shared Secret, você poderá fazer a autorização (OAuth2) com os seus usuários na John Deere. Vamos para o próximo passo.</p><h3>Passo 2: Autorizar com o usuário e pegar os tokens de acesso</h3><p>Antes de pegar os dados (autorizados) dos seus usuários, é necessário que sua aplicação passe pelo fluxo de OAuth2 da John Deere <br>(obs: OAuth1 será desativado pela John Deere em Maio 2021).</p><p>Primeiro, a sua aplicação precisa redirecionar o usuário para uma URL customizada da John Deere em que o usuário fará o login na conta dele e autorizará o acesso da sua aplicação aos dados dele.</p><p>Para construir essa URL, o jeito mais fácil é mandar um POST para</p><blockquote><a href="https://94kvge1ot0.execute-api.us-east-1.amazonaws.com/get_url">https://94kvge1ot0.execute-api.us-east-1.amazonaws.com/get_url</a></blockquote><p>com o seguinte JSON:</p><pre>{<br>  “client_id”: “Seu John Deere App ID”,<br>  “client_secret”: “Seu John Deere Shared Secret”,<br>  “client_redirect_url”: “URL de redirecionamento da sua aplicação”<br>}</pre><p>obs: &quot;client_id&quot; e &quot;client_secret&quot; são o App ID e o Shared Secret da sua aplicação, obtidos no passo 2.</p><p>A chave&quot;client_redirect_url&quot; é a URL que você adicionou ao seu app da John Deere no passo anterior.</p><p>Após o POST ser realizado, será retornada uma URL que pode ser usada pela sua aplicação para redirecionar o usuário à página da John Deere em que ele irá entrar na conta dele e autorizar a sua aplicação a acessar os dados dele.</p><p>Esse processo deve ser feito para cada usuário e a URL construída só pode ser utilizada uma vez.</p><p>Assim que o usuário clicar em autorizar, a John Deere irá redirecioná-lo à &quot;client_redirect_url&quot; e vai concatenar nessa URL um código que será utilizado pela sua aplicação para obter o token de acesso aos dados dele. Vamos chamar essa URL concatenada com o código de jd_response_url.</p><p><strong>Obter o token de acesso</strong></p><p>Agora só falta pegar o token de acesso à API da John Deere. Para isso, mande um POST para</p><blockquote><a href="https://94kvge1ot0.execute-api.us-east-1.amazonaws.com/get_token">https://94kvge1ot0.execute-api.us-east-1.amazonaws.com/get_token</a></blockquote><p>com o seguinte JSON:</p><pre>{<br>“client_id”: “Seu John Deere App ID”,<br>“client_secret”: “Seu John Deere Shared Secret”,<br>&quot;client_redirect_url&quot;: &quot;URL de redirecionamento do seu app&quot;,<br>“response_url”: “{{jd_response_url}}”<br>}</pre><p>Feita essa chamada, será retornado um JSON contendo o &quot;access_token&quot; e o &quot;refresh_token&quot;. Com esses tokens, sua aplicação pode pegar dados (autorizados) dos seus usuários, como limites dos talhões e dados de operações. No próximo passo vamos mostrar exatamente como fazer isso.</p><h3>Passo 3: Eureka! Acessar os dados autorizados</h3><p>Agora com as credenciais da sua conta de desenvolvedor e os tokens do usuário em mãos , sua aplicação vai poder buscar diversos dados da API da John Deere.</p><p>O jeito mais fácil de buscar esses dados é através da API da Leaf. Nessa publicação você já usou a Leaf e talvez nem tenha notado (no passo 2, ao construir a URL de redirecionamento do seu usuário).</p><p>A API da Leaf facilita o processo de autenticação, de gerenciamento de usuários, renovação de tokens e busca pelos dados autorizados de seus usuários. Além disso, ela processa esses dados para o formato JSON, que é mais fácil de ser trabalhado, e padroniza com os dados de outros provedores, como Climate Field View. Ou seja, sua aplicação vai poder ler arquivos da mesma maneira para múltiplos provedores e trabalhar com arquivos JSON, ao invés de proprietários, onde tudo é mais complicado.</p><p>Criar uma conta na Leaf é totalmente gratuito, basta <a href="https://withleaf.io/registration/">se registrar nesse link</a>. A <a href="https://leaf-agriculture.github.io/docs/docs/index.html">documentação é bem completa</a> (em inglês).</p><p>Agora basta pegar o seu Leaf Token enviando um POST para</p><p><a href="https://api.withleaf.io/api.authenticate">https://api.withleaf.io/api/authenticate</a></p><p>com o seguinte JSON:</p><pre>{<br>&quot;username&quot;: &quot;email da sua conta na Leaf&quot;,<br>&quot;password&quot;: &quot;senha da sua conta na Leaf&quot;<br>}</pre><p>Pronto! Será retornado seu Leaf Token e você vai utilizá-lo na próxima chamada. Agora vamos para a última chamada! Sua aplicação pode criar um usuário com as credenciais da John Deere e a Leaf vai buscar automaticamente os dados disponíveis na conta dele, como dados de operações e os campos (limites de talhão).</p><p>Esse último request é a criação de um Leaf User, que vai representar o seu produtor rural e vai conter os dados dele.</p><p>Para criar o Leaf User, envie um POST para</p><p><a href="https://api.withleaf.io/services/usermanagement/api/users/">https://api.withleaf.io/services/usermanagement/api/users/</a></p><p>Com o seguinte header:</p><pre>Authorization: Bearer {{seu Leaf_Token}}</pre><p>Com o seguinte JSON:</p><pre>{<br>  &quot;name&quot;: &quot;dê um nome para seu usuário&quot;,<br>  &quot;email&quot;: &quot;dê um email para seu usuário&quot;,<br>  &quot;johnDeereCredentials&quot;: {<br>    &quot;clientKey&quot;: &quot;{{jd_client_id}}&quot;,<br>    &quot;clientSecret&quot;: &quot;{{jd_client_secret}}&quot;,<br>    &quot;accessToken&quot;: &quot;{{jd_access_token}}&quot;,<br>    &quot;refreshToken&quot;: &quot;{{jd_refresh_token}}&quot;<br>  }<br>}</pre><p>Pronto! A Leaf busca os dados automaticamente e você pode fazer requisições por eles através de diversos endpoints, como <a href="https://leaf-agriculture.github.io/docs/docs/field_boundaries_endpoints#get-fields">este para pegar os campos</a> e <a href="https://leaf-agriculture.github.io/docs/docs/operations_endpoints#get-files">este para pegar os arquivos de operações</a>, onde você terá acesso a dados que proporcionam o gerenciamento do ciclo operacional de uma cultura agrícola como mapas de colheita, imagens de operações de plantio e de aplicação!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qwuhbJCcbdJ6zyB_saaquA.png" /><figcaption>A Leaf também tem conexões com outros provedores e com imagens satélite! <a href="https://leaf-agriculture.github.io/docs/docs/quickstart">Confira na documentação</a></figcaption></figure><p>Qualquer dúvida ou sugestão, a Leaf está à disposição em help@withleaf.io</p><p>Até a próxima!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2ef332a6037" width="1" height="1" alt=""><hr><p><a href="https://medium.com/leaf-api/como-acessar-dados-autorizados-dos-seus-usu%C3%A1rios-na-john-deere-c2ef332a6037">Como acessar dados autorizados dos seus usuários na John Deere</a> was originally published in <a href="https://medium.com/leaf-api">Leaf API</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Climate Field View authentication with Leaf]]></title>
            <link>https://medium.com/leaf-agriculture/climate-field-view-authentication-with-leaf-386086804f73?source=rss-bc6ed4ddcfe3------2</link>
            <guid isPermaLink="false">https://medium.com/p/386086804f73</guid>
            <category><![CDATA[leaves]]></category>
            <category><![CDATA[agriculture]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[agtech]]></category>
            <dc:creator><![CDATA[G. Bueno]]></dc:creator>
            <pubDate>Wed, 19 Aug 2020 21:07:49 GMT</pubDate>
            <atom:updated>2020-09-14T12:03:34.664Z</atom:updated>
            <content:encoded><![CDATA[<p>Leaf’s API is the easiest way to build with farm data.</p><p>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.</p><p>Here is a link to <a href="http://withleaf.io/">Leaf’s website</a> and <a href="http://learn.withleaf.io/">docs</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LZWgnd1cu71aWCuGPbjzMQ.png" /><figcaption>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.</figcaption></figure><p>In this post, we are going to show you how to easily go through Climate Field View authorization flow with Leaf, that is, get authorized to access your users’ Climate Field View data with Leaf. Let’s get to it!</p><h3>Summary</h3><ul><li><strong>Step 1: </strong>Create a developer account with Climate Field View and get your application credentials</li><li><strong>Step 2:</strong> Get your users’ Climate Field View tokens with Leaf</li><li><strong>Step 3:</strong> Add Climate Field View credentials to Leaf</li></ul><p>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.</p><h3>Step 1: Create a developer account with Climate Field View and get your application credentials</h3><p>(if you already have a developer account with Climate, you can skip this step)</p><p>Creating a Climate Field View developer account is a very simple and automatic process, just register with <a href="https://dev.fieldview.com/join-us/">this link</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S59qwU68mnHf2vY5" /></figure><p>After being approved by Climate, they will provide you a clientId, a clientSecret, and an API Key. You will use these three later.</p><p>After that, you will have created your developer account and can go to the next step of this tutorial.</p><h3>Step 2: Get your users’ Climate tokens with Leaf</h3><p>To get your users’ tokens to access their Climate Field View data, your application must go through Climate Field View OAuth flow. First, you need to redirect the user to a custom URL that is the Climate Field View page that will present the user the choice of authorizing your app to access their data.</p><p>At the end of this step, we will want to have retrieved your user’s climate <em>access token</em> and <em>refresh token</em></p><p>To generate an access token and refresh token, your webapp must direct users to the “Log in with FieldView” page. Once users authenticate on the Climate FieldView site, they’ll be redirected back to your app with a code you’ll use to retrieve the required access tokens.</p><ol><li>Here’s the Interactive login workflow:</li></ol><p>a. The user arrives at your site and clicks the “Log in with FieldView” button. Clicking this button navigates the user’s browser to the Climate FieldView login page on climate.com. The url must be constructed this way (broken down into separate lines for easier reading):</p><pre><a href="https://climate.com/static/app-login/index.html?">https://climate.com/static/app-login/index.html?</a><br><strong>client_id</strong>={client_id}&amp;<br><strong>redirect_uri</strong>={redirect_uri}&amp;<br><strong>response_type</strong>=code&amp;<br><strong>scope</strong>={scope}</pre><p>A fully constructed url example is shown below (again, broken into separate lines to ease reading):</p><pre><a href="https://climate.com/static/app-login/index.html?">https://climate.com/static/app-login/index.html?</a><br><strong>client_id</strong>=partner-dataranch&amp;<br><strong>redirect_uri</strong>=https%3A%2F%2Fleafagriculture.com.br<br><strong>response_type</strong>=code&amp;<br><strong>scope</strong>=soil%3Awrite%20openid%20fields%3Aread%20farmOrganizations%3Aread%20resourceOwners%3Aread%20platform%20partnerapis</pre><ul><li><strong>scope</strong>: This is the list of scopes corresponding to the endpoints you intend to call after authenticating. This list should be as specific as possible, since the user will be asked to grant permissions for each requested scope. The value must be a space-delimited, URL-encoded list (e.g., fields:read imagery:write). Here is a list of scopes corresponding to each resource/endpoint:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/adb98581eb2042fdb4aa98ca880c87ba/href">https://medium.com/media/adb98581eb2042fdb4aa98ca880c87ba/href</a></iframe><ul><li><strong>redirect_uri</strong>: The redirect_uri in the query must be a fully qualified, URL-encoded URI on your server. That’s where the code is going to be received.</li><li><strong>client_id</strong>: This is the OAuth2 client ID provided to you by Climate.</li><li><strong>response_type</strong>: This specifies this request is for an authorization code.</li></ul><p>b. The user enters a valid Climate FieldView username and password and clicks Log In.</p><p>c. The user is then prompted to confirm that the partner app should be allowed access. This prompt is branded with your logo. The user clicks Allow.</p><p>d. The user’s browser is redirected back to your site.</p><p>2. After the user authenticates and allows access to the partner app, the <em>redirect_uri</em> specified in the authorization request receives a single query parameter named <em>code</em>. You then use this code to request an access token from Climate, via a backend web service call.</p><p>This temporary code, which expires in about 1 minute, is used to generate the initial access token.</p><p><strong>Get the user’s tokens</strong></p><p>Now, let&#39;s get the user’s tokens.</p><p>First, you will need to calculate the authorization header for the next call. It looks like this:</p><blockquote>Basic {base64_encode($clientId:$clientSecret)}</blockquote><p>We&#39;ve included a brief Javascript code that calculates it for you:</p><pre>// let&#39;s first concatenate client_id, &quot;:&quot;, and client_secret<br>var id_sec = cfv_client_id + “:” + cfv_client_secret;</pre><pre>// now let&#39;s encode to Base64<br>var id_sec_64 = btoa(id_sec);</pre><pre>// finally, let&#39;s concatenate with &quot;Basic &quot;<br>var authorization_code = “Basic “ + id_sec_64;</pre><p>To check if your code is working, make sure that given</p><pre>clientId = &quot;<em>leaf</em>&quot; and clientSecret = &quot;<em>agriculture</em>&quot;</pre><p>It will generate the Authorization Header</p><pre>Basic bGVhZjphZ3JpY3VsdHVyZQo</pre><p>Ok! We are ready to make the request.<br>Once users authenticate on the Climate Field View website, they’ll be redirected back to your app and your app will use the code in the response URL to get the user’s tokens.</p><p>A code looks like this: c858cfa6–6e22–31d9–9d94-d0ac7dcaa6e6</p><p>Your application must grab this code and just send aPOST to</p><blockquote><a href="https://api.climate.com/api/oauth/token">https://api.climate.com/api/oauth/token</a></blockquote><p>with the following body (x-www-form-urlencoded):</p><pre>“code”: “cfv_code”,<br>“redirect_uri”: “cfv_redirect_uri”,<br>“grant_type”: “authorization_code”</pre><p>A JSON containing the tokens will be returned, and you can add them to Leaf as Climate Field View credentials.</p><p><em>note: Leaf will manage each and every token, making sure they are always refreshed and valid.</em></p><h3>Step 3: Add your Climate credentials to Leaf</h3><p>Leaf’s API uses an abstraction called <strong>Leaf User</strong> to store credentials and organize data for each individual data owner. In most cases, the Leaf User will be the farmer or consultant that has access to the source data inside the machinery company’s <em>FMIS</em> (e.g. John Deere Operations Center or Climate Field View platform).</p><p>Leaf’s API must then be initiated with Climate FieldView credentials in order to access and standardize Climate FieldView data.</p><p>Just send a POST request to</p><blockquote><a href="https://api.withleaf.io/services/usermanagement/api/climate-field-view-credentials">https://api.withleaf.io/services/usermanagement/api/climate-field-view-credentials</a></blockquote><p>With the following Header:</p><pre>Authorization: Bearer {{your_leaf_token}}</pre><p><em>note: </em><a href="https://leaf-agriculture.github.io/docs/docs/quickstart#authentication"><em>here’s how to get your leaf_token</em></a></p><p>And the following JSON:</p><pre>{<br>  &quot;clientId&quot;: &quot;{{cfv_client_id}}&quot;,<br>  &quot;clientSecret&quot;: &quot;{{cfv_client_secret}}&quot;,<br>  &quot;apiKey&quot;: &quot;{{cfv_api_key}}&quot;,<br>  &quot;refreshToken&quot;: &quot;{{cfv_refresh_token}}&quot;<br>}</pre><p>Excellent!</p><p>Leaf will return an id to that credential. Now you can attach these credentials to your Leaf User and query for their data!</p><p>If you don’t have a Leaf User or don’t know how to attach credentials to one, just check our docs on <a href="https://leaf-agriculture.github.io/docs/docs/user_management_endpoints#post-users">how to create a Leaf User</a> or <a href="https://leaf-agriculture.github.io/docs/docs/user_management_endpoints#put-users">how to attach credentials to one</a>.</p><p>See ya!</p><p><em>— — — <br>Special thanks to </em><a href="https://medium.com/u/8aee43c95df8"><em>Luiz H. Z. Santana</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=386086804f73" width="1" height="1" alt=""><hr><p><a href="https://medium.com/leaf-agriculture/climate-field-view-authentication-with-leaf-386086804f73">Climate Field View authentication with Leaf</a> was originally published in <a href="https://medium.com/leaf-agriculture">Leaf blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>