Sample code for 30+ languages & platforms
Java Requires Chilkat v11.0.0+

BrickLink OAuth1 using Chilkat HTTP

See more BrickLink Examples

Demonstrates sending an api.bricklink.com request with OAuth1 authentication using Chilkat HTTP.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.HttpResponse;
import com.chilkatsoft.chilkat2.JsonObject;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example assumes the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Http http = new Http();

        http.setOAuth1(true);
        http.setOAuthConsumerKey("Your Consumer Key");
        http.setOAuthConsumerSecret("Your Consumer Secret");
        http.setOAuthToken("Your OAuth1 Token");
        http.setOAuthTokenSecret("Your Token Secret");
        http.setOAuthSigMethod("HMAC-SHA1");

        HttpResponse resp = new HttpResponse();
        try {
            http.httpNoBody("GET", "https://api.bricklink.com/api/store/v1/orders?direction=in", resp);
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        System.out.println("Response status code = " + resp.getStatusCode());

        JsonObject json = new JsonObject();
        resp.getBodyJson(json);

        json.setEmitCompact(false);
        System.out.println(json.emit());
    }
}