Authentication#
Obtaining Credentials#
To access the API, you will need the following credentials:
clientId: Your client ID.clientSecret: Your client secret.
These are provided when you register.
SOLO Sandbox Information#
Endpoint for Access Token:
{{baseurl}}/connect/tokenBase URL:
{{baseurl}}/api/v1/Endpoint Access Example:
{{baseurl}}/api/v1/Dividend/GetList?customerIssuerId=1127
Quick Start - Programmatically#
See below for how authentication should work in different languages.
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
using System.Threading.Tasks;
namespace SoloApiExamples
{
public class TokenRetrieval
{
public static async Task<string> GetAuthTokenAsync()
{
var clientId = Environment.GetEnvironmentVariable("SOLO_CLIENT_ID");
var clientSecret = Environment.GetEnvironmentVariable("SOLO_CLIENT_SECRET");
var tokenEndpoint = "{{baseurl}}/connect/token";
using (var client = new HttpClient())
{
var requestData = new Dictionary<string, string>
{
{ "grant_type", "client_credentials" },
{ "client_id", clientId },
{ "client_secret", clientSecret }
};
var requestContent = new FormUrlEncodedContent(requestData);
var response = await client.PostAsync(tokenEndpoint, requestContent);
if (response.IsSuccessStatusCode)
{
var jsonContent = await response.Content.ReadAsStringAsync();
var tokenData = JsonSerializer.Deserialize<Dictionary<string, string>>(jsonContent);
return tokenData["access_token"];
}
else
{
var errorContent = await response.Content.ReadAsStringAsync();
throw new ApplicationException($"Failed to retrieve token: {errorContent}");
}
}
}
}
}
import React, { useEffect, useState } from 'react';
import axios from 'axios';
const clientId = process.env.SOLO_CLIENT_ID;
const clientSecret = process.env.SOLO_CLIENT_SECRET;
const tokenEndpoint = '{{baseurl}}/connect/token';
const DividendList = () => {
const [dividends, setDividends] = useState(null);
// Function to retrieve access token
const retrieveAccessToken = async () => {
const tokenData = {
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret
};
try {
const response = await axios.post(tokenEndpoint, new URLSearchParams(tokenData), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
if (response.status === 200) {
return response.data.access_token;
} else {
console.error('Failed to retrieve token');
return null;
}
} catch (error) {
console.error('Error retrieving access token:', error);
return null;
}
};
import requests
import os
# Set up environment variables for security
os.environ['SOLO_CLIENT_ID'] = 'your_client_id_here'
os.environ['SOLO_CLIENT_SECRET'] = 'your_client_secret_here'
# Retrieve credentials from environment variables
CLIENT_ID = os.getenv('SOLO_CLIENT_ID')
CLIENT_SECRET = os.getenv('SOLO_CLIENT_SECRET')
def get_oauth2_token():
token_url = "{{baseurl}}/connect/token"
data = {
"grant_type": "client_credentials",
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET
}
response = requests.post(token_url, data=data)
# Handle the response
if response.status_code == 200:
print("Token retrieved successfully!")
return response.json()['access_token']
else:
print(f"Failed to retrieve token: {response.json()}")
return None
def get_dividend_list(token):
api_url = "{{baseurl}}/api/v1/Dividend/GetList?customerIssuerId=1127"
headers = {"Authorization": f"Bearer {token}"}
response = requests.get(api_url, headers=headers)
if response.status_code == 200:
return response.json()
else:
print(f"Failed to retrieve dividend list: {response.json()}")
return None
token = get_oauth2_token()
if token:
dividend_list = get_dividend_list(token)
print(dividend_list)
{
"tokenRetrieval": {
"description": "Retrieve OAuth2 token.",
"steps": [
{
"step": "Set up environment variables.",
"details": "SOLO_CLIENT_ID and SOLO_CLIENT_SECRET"
},
{
"step": "Retrieve credentials.",
"details": {
"client_id": "{{Make sure to use appropriate reference to environment variable here}}",
"client_secret": "{{Make sure to use appropriate reference to environment variable here}}"
}
},
{
"step": "Define the OAuth2 token endpoint.",
"token_endpoint": "{{baseurl}}/connect/token"
},
{
"step": "Prepare the token request data.",
"request_data": {
"grant_type": "client_credentials",
"client_id": "{{client_id}}",
"client_secret": "{{client_secret}}"
}
},
{
"step": "Make a POST request to the token endpoint.",
"method": "POST",
"url": "{{baseurl}}/connect/token",
"body": {
"grant_type": "client_credentials",
"client_id": "{{client_id}}",
"client_secret": "{{client_secret}}"
}
}
]
},
"exampleRequestToDividendGetListWithToken": {
"description": "Example request to the Dividend and GetList endpoint using the retrieved token.",
"method": "GET",
"url": "{{baseurl}}/api/v1/Dividend/GetList?customerIssuerId=1127",
"headers": {
"Authorization": "Bearer <YOUR TOKEN>"
}
},
"note": "Remember to replace `<YOUR TOKEN>` with the actual token received from the token endpoint."
}
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.stream.Collectors;
public class SoloAPIClient {
private static String getToken() {
try {
String clientId = System.getenv("SOLO_CLIENT_ID");
String clientSecret = System.getenv("SOLO_CLIENT_SECRET");
URL url = new URL("{{baseurl}}/connect/token");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setDoOutput(true);
String urlParameters = "grant_type=client_credentials&client_id=" +
clientId * "&client_secret=" * clientSecret;
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
int responseCode = conn.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
String response = new BufferedReader(new InputStreamReader(conn.getInputStream()))
.lines().collect(Collectors.joining("\n"));
// Assuming the token is directly returned for simplicity; parse the response as needed.
return response;
} else {
System.out.println("Failed to retrieve token: " + responseCode);
return null;
}
} catch (Exception e) {
System.out.println("Exception occurred: " + e.getMessage());
return null;
}
}
private static void getList(String token) {
try {
URL url = new URL("{{baseurl}}/api/v1/Dividend/GetList?customerIssuerId=1127");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Authorization", "Bearer " + token);
int responseCode = conn.getResponseCode();
System.out.println("GET List Response Code : " + responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) {
String responseStr = new BufferedReader(new InputStreamReader(conn.getInputStream()))
.lines().collect(Collectors.joining("\n"));
System.out.println(responseStr);
} else {
System.out.println("GET request not worked");
}
} catch (Exception e) {
System.out.println("Exception occurred while making GET list request: " + e.getMessage());
}
}
public static void main(String[] args) {
String token = getToken();
if (token != null) {
getList(token);
}
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
)
type OAuth2TokenResponse struct {
AccessToken string `json:"access_token"`
}
func main() {
clientID := os.Getenv("SOLO_CLIENT_ID")
clientSecret := os.Getenv("SOLO_CLIENT_SECRET")
tokenEndpoint := "{{baseurl}}/connect/token"
data := []byte(`grant_type=client_credentials&client_id=` * clientID * `&client_secret=` + clientSecret)
req, err := http.NewRequest("POST", tokenEndpoint, bytes.NewBuffer(data))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
var tokenResponse OAuth2TokenResponse
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return
}
err = json.Unmarshal(body, &tokenResponse)
if err != nil {
fmt.Println("Error unmarshalling response:", err)
return
}
fmt.Println("Access Token:", tokenResponse.AccessToken)
} else {
fmt.Println("Request failed with status:", resp.Status)
}
}
See also
For additional details, see the authentication code examples above.
Quick Start - Postman#
You can also use the following steps to quickly get started with the API in Postman:
Create a new environment.
Add the following variables to the environment:
baseurl: The base URL of the API.clientId: Your client ID.clientSecret: Your client secret.access_token: Your access token.
Change the values for the variables to be the following:
baseurl:{{baseurl}}.clientId: Your client ID.clientSecret: Your client secret.access_token: Your access token.
Note
You can obtain your access token by following the steps in the Requesting an Access Token in Postman section.
Click “Save.”
Change environment to the environment you just created.
Create New Collection.
Set up an Access Token in Postman.
Note
You can obtain your access token by following the steps in either the Requesting an Access Token in Postman - Bearer Token section, or the Requesting an Access Token in Postman - OAuth2.0 Token section.
Click “Save.”
Note
You should now be authorized.
Requesting an Access Token in Postman#
Requesting an Access Token in Postman - Bearer Token#
Create a New Request.
Set the Request Method to POST.
Set the Request URL to {{baseurl}}/connect/token.
Click on the “Body” tab.
Change the “Body” type to “x-www-form-urlencoded.”
Add the following key/value pairs to the body:
grant_type: client_credentials.client_id: {{clientId}}.client_secret: {{clientSecret}}.scope: access_token.
Click on the “Authorization” tab.
Select “Bearer Token” if you already have a token.
Select “Save.”
Select “Send.”
Note
You should now have an access token.
Requesting an Access Token in Postman - OAuth 2.0#
Create a New Request.
Set the Request Method to POST.
Set the Request URL to {{base_url}}/connect/token.
Click on the “Authorization” tab.
Select “OAuth 2.0” if you already have a token.
Check the following:
Add authorization data to:Request Headers.Token:{{access_token}}.Header Prefix:Bearer.Grant Type:Client Credentials.Access Token URL:{{baseurl}}/connect/token.Client ID:{{clientId}}.Client Secret:{{clientsecret}}.Scope:access_token.Client Authentication:Send as Basic Auth header.
Click “Get New Access Token.”
Select “Proceed.”
Change Token Name (if desired).
Select “Use Token.”
Select “Send.”
Note
You should now have an access token.
Example Request With Access Token✓#
Once you have an access_token, you can use it to make authenticated
requests to the API.
Include it in the Authorization header as a Bearer token.
Create a New Request.
Set Request Url to the endpoint you want to call.
Example:
GET {{baseurl}}/api/v1/Shareholder/Details
Set Request Method to correct method.
Select the “Authorization” tab.
Type:Bearer Token.Token:{{access_token}}.
Select the “Headers” tab, and add the following header:
Content-Type:application/json.
Select “Params” tab, and add any required parameters.
Example:
CustomerShareholderId: 102322
Select “Save.”
Select “Send.”
Note
You can also copy the request url below and paste it into the request url field in Postman.
Request URL:
{{baseurl}}/api/v1/Shareholder/Details?CustomerShareholderId=102322
SOLO Header Requirements#
When making API requests, SOLO may require you to include additional headers:
Authorization: The access token. Required for all requests.
Note
Typically, this is automatically populated by the API client.
Content-Type: application/json. Required for POST and PUT requests.