Authentication - API

Getting Started

Available libraries

Authenticate Users

Get Data

Parse Data

API settings



Mobile setup


API


Widget


Request


Receive


Events


Data Models

Overview of Authenticating with API

Terra allows you to connect with our widget or to create your own using our API.

By using our /v2/auth/authenticateUser endpoint, you can send a payload to request to connect with any provider, which you can place in the resource payload.

import requests

url = "https://api.tryterra.co/v2/auth/authenticateUser"

headers = {
    "accept": "application/json",
    "dev-id": "DEV-ID",
    "content-type": "application/json",
    "x-api-key": "API-KEY",
}

data = {
  "resource": "RESOURCE_NAME",
}

response = requests.post(url, headers=headers params=data)
const options = {
  method: 'POST',
  headers: {
    accept: 'application/json',
    'dev-id': 'DEV-ID',
    'content-type': 'application/json',
    'x-api-key': 'API-KEY'
  },
  body: {
  	'resource': 'RESOURCE_NAME'
  }
};

fetch('https://api.tryterra.co/v2/auth/authenticateUser', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.tryterra.co/v2/auth/authenticateUser")
  .post(null)
  .addHeader("accept", "application/json")
  .addHeader("dev-id", "DEV-ID")
  .addHeader("content-type", "application/json")
  .addHeader("x-api-key", "API-KEY")
  .addBody("resource", "RESOURCE_NAME")
  .build();

Response response = client.newCall(request).execute();

Upon sending this request, you will receive an authentication URL, which you can use to post the username and password of your user to. Once you have done so, your webhook endpoint will receive a user-authentication payload.

import requests

url = "AUTHENTICATION_URL"

headers = {
    "accept": "application/json",
    "dev-id": "DEV-ID",
    "content-type": "application/json",
    "x-api-key": "API-KEY"
}

data = {
		"username": "USERNAME",
  	"password": "PASSWORD"
}

response = requests.post(url, headers=headers params=data)
const options = {
  method: 'POST',
  headers: {
    accept: 'application/json',
    'dev-id': 'DEV-ID',
    'content-type': 'application/json',
    'x-api-key': 'API-KEY'
  },
  data: {
    'username': 'USERNAME'
    'password': 'PASSWORD'
	}
};

fetch('AUTHENTICATION_URL', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("AUTHENTICATION_URL")
  .post(null)
  .addHeader("accept", "application/json")
  .addHeader("dev-id", "DEV-ID")
  .addHeader("content-type", "application/json")
  .addHeader("x-api-key", "API-KEY")
  .addData("username", "USERNAME")
  .addData("password", "PASSWORD")
  .build();

Response response = client.newCall(request).execute();