RESTful authentication

Updated

Authenticate RTC REST API requests with Basic HTTP authentication.

RTC REST APIs require Basic HTTP authentication. Generate a Base64-encoded credential with the customer ID and customer secret provided by Agora, then pass the credential in the Authorization request header.

Implement authentication on your server to reduce the risk of credential leakage.

Generate a customer ID and customer secret

  1. In Agora Console, click the username at the bottom of the navigation sidebar to open the account menu, then select RESTful API Keys.

  2. Select Create API Key. Agora generates a customer ID and customer secret.

  3. Select Download and save the file somewhere secure — you can download it only once. In the file, Key is your customer ID and Secret is your customer secret.

  4. Use the customer ID (Key) and customer secret (Secret) to generate a Base64-encoded credential, then pass it to the Authorization request header.

Authorization header

Concatenate the customer ID and customer secret with a colon, encode the result with Base64, then prefix it with Basic.

Authorization: Basic <base64(customer_id:customer_secret)>

For testing and debugging, you can use a Basic Auth header generator. Enter the customer ID as the username and the customer secret as the password.

Basic authentication examples

The following examples send a request to get all projects under your Agora account.

customer_key="Your customer ID"
customer_secret="Your customer secret"
authorization=$(printf "%s:%s" "$customer_key" "$customer_secret" | base64)

curl --request GET 'https://api.agora.io/dev/v1/projects' \
  --header "Authorization: Basic $authorization" \
  --header 'Content-Type: application/json'