HomeGuidesRecipesAPI EndpointsRelease NotesCommunity
Log In
Guides

Authentication & Dependencies

Dependencies

from pprint import pprint
import time
import pandas as pd
import numpy as np

## import REST dependencies
import requests
from requests.auth import HTTPBasicAuth
import json

## Pandas settings (change to your preferences)
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)

Authentication

📘

REST Endpoints Only

This demo will be using our REST methods, so the authentication bearer token will be placed into your headers. Please note that many of these endpoints are also available using the Layar Python SDK, and we will reference them in the tutorial accordingly.

Generate your oauth bearer token for basic authentication. For a full tutorial, please see our guide Configure Your Instance.

curl -X POST -u clientId:clientSecret https://baseUrl.vyasa.com/connect/oauth/token\?grant_type=client_credentials -H "Accept: application/json"
##Gather relevant URLS
envUrl = 'YOUR_ENVIRONMENT_URL'
authUrl = f"{envUrl}/connect/oauth/token"
##ClientID and SecretKey (replace with your own keys)
clientId = 'clientId'
clientSecret = 'clientSecret'
##instantiate token variable
token = requests.post(
        authUrl,
        data={"grant_type" : "client_credentials"},
        auth=HTTPBasicAuth(clientId, clientSecret),
        headers = {'Content-Type' : 'application/x-www-form-urlencoded'},
        ).json()["access_token"]
{"access_token":"2c937b61-1b8c-43dd-b2c2-21893aa8c7e2",
 "token_type":"bearer",
 "expires_in":43075,
 "scope":"read write"}%

Up Next

In the next tutorial, you will learn how to create new Document Sets, apply filters to new or existing Document Sets, and add specialized columns for metadata, sections, QA, and Classification.