Answer the question
In order to leave comments, you need to log in
DonationAlerts API - How to get Code, Token via link?
Hi, I'm having this problem connecting to the DonationAlert API
. At first, DonationAlerts outputs 'Unauthenticated.' then I read that you need to get the code, token using the link:
String API_KEY = "API_TOKEN";
String APP_ID = "APP_ID";
String REDIRECT_URI = "REDIRECT_URI";
String SCOPE = "oauth-donation-index";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://www.donationalerts.com/oauth/authorize?client_id="+ APP_ID + "&redirect_uri=" + REDIRECT_URI + "&response_type=code&scope=" + SCOPE + "oauth-donation-index"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
System.out.println(response);
{"error":"invalid_client","error_description":"Client authentication failed","message":"Client authentication failed"}
Answer the question
In order to leave comments, you need to log in
First you need to collect the link and open it through the browser
Desktop.getDesktop().browse(new URI("https://www.donationalerts.com/oauth/authorize?" + "client_id=" + APP_ID + "&redirect_uri=" + REDIRECT_URI + "&response_type=token" + "&scope=" + SCOPE));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://www.donationalerts.com/api/v1/alerts/donations"))
.header("Authorization", "Bearer " + API)
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Good afternoon.
There is documentation here where you can read in detail:
https://www.donationalerts.com/apidoc
Read from: "1 - Application Registration" to "3 - Getting Access Token"
In your code, you did not define the values of these variables:
String API_KEY = "API_TOKEN";
String APP_ID = "APP_ID";
String REDIRECT_URI = "REDIRECT_URI";
String SCOPE = "oauth-donation-index";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question