New in 2.4: Test runs you can trust See what's new →

Get a temporary request token

POSThttps://api.testingapis.com/api/auth/oauth1/request_token

Get a temporary request token (step 1 of the three-legged flow).

Sign with the consumer credentials only; sending an oauth_token is rejected. oauth_callback is required: an http(s) URL, or oob to have the verifier shown instead of redirected. In Postman, leave the token fields empty and fill in Callback URL under Advanced.

Response: application/x-www-form-urlencoded by default, or JSON when the request sends Accept: application/json. The request token expires after 10 minutes. Next: open GET /api/auth/oauth1/authorize?oauth_token=<request token>.

OAuth 1.0a signature with the consumer credentials only: apibee-consumer-key / apibee-consumer-secret

Parameters 8

NameTypeDescription
oauth_consumer_keyrequiredheader · stringapibee-consumer-key. In the Authorization: OAuth header, the query string or a form body (one place only).
oauth_callbackrequiredheader · stringAn absolute http(s) URL to redirect to after authorization, or oob to get the verifier as JSON.
oauth_signature_methodrequiredheader · stringHMAC-SHA1, HMAC-SHA256, HMAC-SHA512 or PLAINTEXT.
oauth_signaturerequiredheader · stringSigned with the consumer secret only: the signing key is consumer_secret& (empty token secret). For PLAINTEXT, send apibee-consumer-secret%26.
oauth_timestampheader · stringUnix time in seconds, within 5 minutes of server time. Required for the HMAC methods; may be left out for PLAINTEXT.
oauth_nonceheader · stringA random string; each one works once. Required for the HMAC methods; may be left out for PLAINTEXT.
oauth_versionheader · stringOptional. If sent, it must be 1.0.
Acceptheader · stringapplication/json for a JSON response. Without it the response is application/x-www-form-urlencoded.

Responses

200
oauth_token, oauth_token_secret, oauth_callback_confirmed=true and oauth_expires_in (600).
400
parameter_absent (no oauth_callback), parameter_rejected (a bad callback, or an oauth_token was sent), or another protocol parameter problem.
401
consumer_key_unknown, timestamp_refused, nonce_used or signature_invalid.

Example

Request
curl -X POST "https://api.testingapis.com/api/auth/oauth1/request_token" \
  -H "Accept: application/json" \
  -H 'Authorization: OAuth oauth_consumer_key="apibee-consumer-key", oauth_signature_method="PLAINTEXT", oauth_callback="oob", oauth_signature="apibee-consumer-secret%26"'
Run in Studio
Response200 OK
{
  "oauth_token": "o1rt_6112c483e357a56ceb9ea6d5fc7bc9e31e89b4ae",
  "oauth_token_secret": "o1rs_e2e13614310bf304d0cec178961363cc9928cb74",
  "oauth_callback_confirmed": "true",
  "oauth_expires_in": "600"
}

Code examples

JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/auth/oauth1/request_token", {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Authorization": "OAuth oauth_consumer_key=\"apibee-consumer-key\", oauth_signature_method=\"PLAINTEXT\", oauth_callback=\"oob\", oauth_signature=\"apibee-consumer-secret%26\"",
  },
});
console.log(response.status, await response.text());
Python (requests)
import requests

response = requests.request(
    "POST",
    "https://api.testingapis.com/api/auth/oauth1/request_token",
    headers={
        "Accept": "application/json",
        "Authorization": "OAuth oauth_consumer_key=\"apibee-consumer-key\", oauth_signature_method=\"PLAINTEXT\", oauth_callback=\"oob\", oauth_signature=\"apibee-consumer-secret%26\"",
    },
    allow_redirects=False,
)
print(response.status_code, response.text)
Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newBuilder()
            .followRedirects(HttpClient.Redirect.NEVER)
            .build();

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.testingapis.com/api/auth/oauth1/request_token"))
            .header("Accept", "application/json")
            .header("Authorization", "OAuth oauth_consumer_key=\"apibee-consumer-key\", oauth_signature_method=\"PLAINTEXT\", oauth_callback=\"oob\", oauth_signature=\"apibee-consumer-secret%26\"")
            .method("POST", HttpRequest.BodyPublishers.noBody())
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}