Before using an Agora RESTful API, you need to setup REST authentication.
Available REST authentication methods are:
- 
Basic HTTP authentication
You need to generate a Base64-encoded credential with the Customer ID and Customer Secret provided by Agora and pass the credential to the Authorization parameter in the request header.
 
Implement authentication on the server; otherwise, you may encounter the risk of data leakage.
To generate a set of Customer ID and Customer Secret, do the following:
- 
In Agora Console, click the account name in the top right corner, and click RESTful API from the drop-down list to enter the RESTful API page.

 
- 
Click Add a secret, and click OK. A set of Customer ID and Customer Secret is generated.
 
- 
Click Download in the Customer Secret column. Read the pop-up window carefully, and save the downloaded key_and_secret.txt file in a secure location.
 
- 
Use the Customer ID (key) and Customer Secret (secret) to generate a Base64-encoded credential, and pass the Base64-encoded credential to the Authorization parameter in the HTTP request header.
 
You can download the Customer Secret from Agora Console only once. Be sure to keep it secure.
The following sample codes implement basic HTTP authentication and send a request with the Server RESTful API to get the basic information of all current Agora projects.
_40import java.io.IOException;
 _40import java.net.http.HttpClient;
 _40import java.net.http.HttpRequest;
 _40import java.net.http.HttpResponse;
 _40import java.util.Base64;
 _40// HTTP basic authentication example in Java using the <Vg k="VSDK" /> Server RESTful API
 _40public class Base64Encoding {
 _40    public static void main(String[] args) throws IOException, InterruptedException {
 _40        final String customerKey = "Your customer ID";
 _40        final String customerSecret = "Your customer secret";
 _40        // Concatenate customer key and customer secret and use base64 to encode the concatenated string
 _40        String plainCredentials = customerKey + ":" + customerSecret;
 _40        String base64Credentials = new String(Base64.getEncoder().encode(plainCredentials.getBytes()));
 _40        // Create authorization header
 _40        String authorizationHeader = "Basic " + base64Credentials;
 _40        HttpClient client = HttpClient.newHttpClient();
 _40        // Create HTTP request object
 _40        HttpRequest request = HttpRequest.newBuilder()
 _40                .uri(URI.create("https://api.agora.io/dev/v1/projects"))
 _40                .header("Authorization", authorizationHeader)
 _40                .header("Content-Type", "application/json")
 _40        HttpResponse<String> response = client.send(request,
 _40                HttpResponse.BodyHandlers.ofString());
 _40        System.out.println(response.body());
 
_54// HTTP basic authentication example in Golang using the <Vg k="VSDK" /> Server RESTful API
 _54  customerKey := "Your customer ID"
 _54  customerSecret := "Your customer secret"
 _54  // Concatenate customer key and customer secret and use base64 to encode the concatenated string
 _54  plainCredentials := customerKey + ":" + customerSecret
 _54  base64Credentials := base64.StdEncoding.EncodeToString([]byte(plainCredentials))
 _54  url := "https://api.agora.io/dev/v1/projects"
 _54  payload := strings.NewReader(``)
 _54  client := &http.Client {
 _54  req, err := http.NewRequest(method, url, payload)
 _54  // Add Authorization header
 _54  req.Header.Add("Authorization", "Basic " + base64Credentials)
 _54  req.Header.Add("Content-Type", "application/json")
 _54  res, err := client.Do(req)
 _54  defer res.Body.Close()
 _54  body, err := ioutil.ReadAll(res.Body)
 _54  fmt.Println(string(body))
 
_41// HTTP basic authentication example in PHP using the <Vg k="VSDK" /> Server RESTful API
 _41$customerKey = "Your customer ID";
 _41$customerSecret = "Your customer secret";
 _41// Concatenate customer key and customer secret
 _41$credentials = $customerKey . ":" . $customerSecret;
 _41$base64Credentials = base64_encode($credentials);
 _41// Create authorization header
 _41$arr_header = "Authorization: Basic " . $base64Credentials;
 _41curl_setopt_array($curl, array(
 _41  CURLOPT_URL => 'https://api.agora.io/dev/v1/projects',
 _41  CURLOPT_RETURNTRANSFER => true,
 _41  CURLOPT_ENCODING => '',
 _41  CURLOPT_MAXREDIRS => 10,
 _41  CURLOPT_TIMEOUT => 0,
 _41  CURLOPT_FOLLOWLOCATION => true,
 _41  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 _41  CURLOPT_CUSTOMREQUEST => 'GET',
 _41  CURLOPT_HTTPHEADER => array(
 _41    'Content-Type: application/json'
 _41$response = curl_exec($curl);
 _41if($response === false) {
 _41    echo "Error in cURL : " . curl_error($curl);
 
_50using System.Collections;
 _50using System.Collections.Generic;
 _50using UnityEngine.Networking;
 _50public class NewBehaviourScript : MonoBehaviour
 _50    // Start is called before the first frame update
 _50        StartCoroutine(FetchRtcToken());
 _50    // Update is called once per frame
 _50    IEnumerator FetchRtcToken()
 _50        string customerKey = "";
 _50        string customerSecret = "";
 _50        // Concatenate customer key and customer secret and use base64 to encode the concatenated string
 _50        string plainCredential = customerKey + ":" + customerSecret;
 _50        // Encode with base64
 _50        byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainCredential);
 _50        string encodedCredential = "Basic " + Convert.ToBase64String(plainTextBytes);
 _50        // Gets the information on all your Agora projects.
 _50        string query_url = $"https://api.agora.io/dev/v1/projects";
 _50        Debug.Log("Query : " + query_url);
 _50        UnityWebRequest request = UnityWebRequest.Get(query_url);
 _50        request.SetRequestHeader("Authorization", encodedCredential);
 _50        Debug.Log("Making Request");
 _50        yield return request.SendWebRequest();
 _50        if(request.result == UnityWebRequest.Result.ProtocolError || request.result == UnityWebRequest.Result.ConnectionError)
 _50            Debug.Log(request.error);
 _50        Debug.Log(request.downloadHandler.text);
 
_39// HTTP basic authentication example in node.js using the <Vg k="VSDK" /> Server RESTful API
 _39const https = require('https')
 _39const customerKey = "Your customer ID"
 _39const customerSecret = "Your customer secret"
 _39// Concatenate customer key and customer secret and use base64 to encode the concatenated string
 _39const plainCredential = customerKey + ":" + customerSecret
 _39encodedCredential = Buffer.from(plainCredential).toString('base64')
 _39authorizationField = "Basic " + encodedCredential
 _39// Set request parameters
 _39  hostname: 'api.agora.io',
 _39  path: '/dev/v1/projects',
 _39    'Authorization':authorizationField,
 _39    'Content-Type': 'application/json'
 _39// Create request object and send request
 _39const req = https.request(options, res => {
 _39  console.log(`Status code: ${res.statusCode}`)
 _39  res.on('data', d => {
 _39    process.stdout.write(d)
 _39req.on('error', error => {
 
_35# HTTP basic authentication example in python using the <Vg k="VSDK" /> Server RESTful API
 _35customer_key = "Your customer ID"
 _35customer_secret = "Your customer secret"
 _35# Concatenate customer key and customer secret and use base64 to encode the concatenated string
 _35credentials = customer_key + ":" + customer_secret
 _35base64_credentials = base64.b64encode(credentials.encode("utf8"))
 _35credential = base64_credentials.decode("utf8")
 _35# Create connection object with basic URL
 _35conn = http.client.HTTPSConnection("api.agora.io")
 _35# Create Header object
 _35# Add Authorization field
 _35headers['Authorization'] = 'basic ' + credential
 _35headers['Content-Type'] = 'application/json'
 _35conn.request("GET", "/dev/v1/projects", payload, headers)
 _35res = conn.getresponse()
 _35print(data.decode("utf-8"))