question

jcpearce avatar image
jcpearce asked bryanvargas edited

Feeling like a dummy here, getting just the OAuth token

I am moving from Payeezy to use the new Clover API's for a web based background task (no GUI or user interaction)

I can see how to process a transaction once I get the bearer token but I can't seem to get this first step in Java to work, for in the simple example below (clientid, secret is made up). What am I missing? Thanks for any pointers


String clientId = "9QBY5ZWD0FDFJM";
String clientSecret = "f94599b7-525a-###-##########";

HttpClient client = HttpClient.newHttpClient();

Gson gson = new Gson();

// Create JSON object
JsonObject requestBody = new JsonObject();
requestBody.addProperty("client_id", clientId);
requestBody.addProperty("client_secret", clientSecret);

// Convert to JSON string
String jsonBody = gson.toJson(requestBody);
System.out.println("Sending: "+jsonBody);

HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://sandbox.dev.clover.com/v3/merchants/oauth"))
        .header("Content-Type", "application/json")
        .POST(HttpRequest.BodyPublishers.ofString(jsonBody))
        .build();


HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

// Parse access token from JSON response
String accessToken = parseAccessToken(response.body());


OAuthremote pay java
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community