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 Developer Toolkit > RESTful API.
  2. Click Add a secret, then click OK. Agora generates a customer ID and customer secret.
  3. Click Download in the Customer Secret column. Read the prompt carefully and save the downloaded key_and_secret.txt file in a secure location.
  4. Use the customer ID and customer secret to generate a Base64-encoded credential, then pass it to the Authorization request header.

You can download the customer secret from Agora Console only once. Keep it secure.

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'