How to create a M2M app

A step by step guide to create your machine to machine applications

How to Sign Up for a Varda Account and Set Up an OAuth M2M Application


1. Sign Up for a Varda Account

  • Visit account.varda.ag.
  • Click on the 'Sign Up' link.
  • Follow the on-screen instructions to create an account. You can sign up using a social account (Google or Microsoft) or by using your email and a password.

2. Register a New OAuth M2M Application

  • After logging in, go to the section for creating a new application.
  • Provide a friendly name for your application.
  • Select the API type 'GFID Standard Account' (this should be the only API type available).

3. Generate an Access Token for the API

  • To access the API, you'll need to generate a token. Replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET with your actual credentials, which you can find in the details of your M2M application.
  • Run the following command in your terminal:
curl ––request POST \
  ––url <https://auth.varda.ag/oauth/token> \
  ––header 'content-type: application/json' \
  ––data '{"client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET","audience":"<https://api.varda.ag/fid/","grant_type":"client_credentials"}'>

4. Accessing the Global Field ID API

  • Include the generated token in the authorization header of your API requests.
  • Example of an authorization header: Authorization: Bearer YOUR_ACCESS_TOKEN

5. Token Management in Your Project

  • To ensure your API calls always have a valid token, implement a function in your project to fetch and store a token initially.
  • Check API responses for token expiration. If a token timeout occurs, refresh the token by requesting a new one and retry the last call.

API Token Request Parameters

  • Method: POST
  • URL: https://auth.varda.ag/oauth/token
  • Body Parameters:
    • client_id: string (required)
    • client_secret: string (required)
    • audience: string (required)
    • grant_type: string (required)

By following these steps, you can successfully sign up for a Varda account, register an M2M application, and manage your API tokens effectively.