HomeGuidesRecipesAPI EndpointsRelease NotesCommunity
Log In

How to Get API Keys

How to generate the API keys you need in order to make calls to the API.

❗️

Do Not Share Authentication Keys

Like a user's login credentials (e.g. a username and password), these keys are private. The client ID and secret you generate for the API are attached to your account. You do not want to share these credentials, or the tokens generated with them, to anyone.

Generating Your API Keys

In order to use the Layar API, you’ll need to generate an OAuth2 session token. In order to do so, you will need an API client ID and client secret (aka your authentication keys), which are going to be different than the account username and password credentials that you use in the Layar user interface.

There are several ways you can generate these credentials: manually via your account profile or the Layar user interface, or programmatically via the REST API. All available methods will be detailed below.

🚧

Minimize How Often You Generate New API Keys

These keys are used to generate short-term access tokens, which are then used to make your API calls. To save your SecOps teams some headache, we suggest storing your keys in a secure location, and only generating new API keys if you believe you are at risk of an attack, or if you must update on a scheduled basis for security compliance.

Instead of generating new keys, we suggest regularly refreshing your access tokens (more information here).

Option 1. Using the Account Page (Recommended)

You can get your account page by navigating to your-instance.vyasa.com/account, where your_instance is the name of your client Layar instance.

  1. Under the Profile tab, you'll see a section for API Keys.
    • If you need to generate keys, or are looking to generate new API keys, click "Generate New API Access Keys".
    • If you've already generated a set of keys, you can click "Get existing keys" to access those keys.
4340
  1. Use the clipboard icon to copy your client ID and client secret and store in a safe place. They will be your clientKey and clientSecret parameters for configuring your instance.
946

Option 2. Using the Layar Interface

  1. To the right of the Application Navigation Menu, is the Layar Systems Settings menu. Click the three dot icon to open up the settings. Alternatively you can get your Layar home page by navigating to your-instance.vyasa.com/layarweb, where your_instance is the name of your client Layar instance.
  2. Click on the "Generate API Access Token" option to generate new API keys.
3920
  1. Copy your client ID and client secret and store in a safe place. They will be your clientKey and clientSecret parameters for configuring your instance.
852

Option 3. Using the RESTful API

## import dependencies
import requests
import json

## Provide Your Client Instance
base_url = 'https://your-instance.vyasa.com'

## Make RESTful call
response = requests.post(f"{base_url}/connect/register/createClientId",            
    headers = {
        'accept':'application/json',
        'content-Type':'application/json',
        'authorization':f"Bearer {configuration.access_token}",
        'X-Vyasa-Client': 'layar' # Note the Vyasa Client is Layar
    }
)

response.json()

Expected response:

{'accessTokenValiditySeconds': 43200,
 'additionalInformation': {'createdByUser': 12345,
  'dateCreated': 1672861032585,
  'description': None},
 'authorities': [{'authority': 'ROLE_CLIENT'}],
 'authorizedGrantTypes': ['refresh_token', 'client_credentials'],
 'autoApproveScopes': None,
 'clientId': 'AbcDefghij',
 'clientSecret': 'LMnOP12q3rS4tUvWxYZABcDE',
 'refreshTokenValiditySeconds': 2592000,
 'registeredRedirectUri': None,
 'resourceIds': ['cortex'],
 'scope': ['read', 'write'],
 'scoped': True,
 'secretRequired': True}

Up Next

Now that you have your client ID and secret, you can use these keys as input to generate an access token for your API session.