Hi guys im quite new to programming in general

I am following the docs and checking the Tinker project but am still stuck at sending Oauth requesst

This is my code.
`
public class CreateOauthClient {
private static final String clientID = "---";
private static final String clientSecret = "---";
private static final String redirectURL = "---";
private static final String apiRequestUrl = "https://oauth.bunq.com/auth";
private static final String responseTYPE = "code";

public static void getOauthRequest() throws IOException {
    CloseableHttpClient httpClient = HttpClients.createDefault();
    HttpPost httpPost = new HttpPost(apiRequestUrl);

    String request = "https://oauth.bunq.com/?" +
            "response_type=" + responseTYPE + "&" +
            "client_id=" + clientID + "&" +
            "redirect_uri=" + redirectURL + "&" +
            "state=594f5548-6dfb-4b02-8620-08e03a9469e6";

    httpPost.setEntity(new StringEntity(request));

    CloseableHttpResponse response = httpClient.execute(httpPost);
    String result = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);

    System.out.println(result);
    httpClient.close();

}

}
`

i am getting this as response

<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="preconnect" href="https://fonts.gstatic.com"/><link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet"/><title>OAuth</title><link rel="shortcut icon" href="/dist/icon/favicon.ico" type="image/ico"/><link rel="apple-touch-icon-precomposed" sizes="57x57" href="/dist/icon/apple-touch-icon-57x57.png"/><link rel="apple-touch-icon-precomposed" sizes="114x114" href="/dist/icon/apple-touch-icon-114x114.png"/><link rel="apple-touch-icon-precomposed" sizes="72x72" href="/dist/icon/apple-touch-icon-72x72.png"/><link rel="apple-touch-icon-precomposed" sizes="144x144" href="/dist/icon/apple-touch-icon-144x144.png"/><link rel="apple-touch-icon-precomposed" sizes="60x60" href="/dist/icon/apple-touch-icon-60x60.png"/><link rel="apple-touch-icon-precomposed" sizes="120x120" href="/dist/icon/apple-touch-icon-120x120.png"/><link rel="apple-touch-icon-precomposed" sizes="76x76" href="/dist/icon/apple-touch-icon-76x76.png"/><link rel="apple-touch-icon-precomposed" sizes="152x152" href="/dist/icon/apple-touch-icon-152x152.png"/><link rel="icon" type="image/png" href="/dist/icon/favicon-196x196.png" sizes="196x196"/><link rel="icon" type="image/png" href="/dist/icon/favicon-96x96.png" sizes="96x96"/><link rel="icon" type="image/png" href="/dist/icon/favicon-32x32.png" sizes="32x32"/><link rel="icon" type="image/png" href="/dist/icon/favicon-16x16.png" sizes="16x16"/><link rel="icon" type="image/png" href="/dist/icon/favicon-128x128.png" sizes="128x128"/><meta name="application-name" content="OAuth"/><meta name="msapplication-TileColor" content="#FFFFFF"/><meta name="msapplication-TileImage" content="/dist/icon/mstile-144x144.png"/><meta name="msapplication-square70x70logo" content="/dist/icon/mstile-70x70.png"/><meta name="msapplication-square150x150logo" content="/dist/icon/mstile-150x150.png"/><meta name="msapplication-wide310x150logo" content="/dist/icon/mstile-310x150.png"/><meta name="msapplication-square310x310logo" content="/dist/icon/mstile-310x310.png"/><script defer="defer" src="/dist/oauth.45e8c61976c919b28a32.js"></script><link href="/dist/oauth.bebede9c5b0e985dfba4.css" rel="stylesheet"></head><body><div id="root"></div><script src="https://kit.fontawesome.com/f22bbf8f51.js" crossorigin="anonymous"></script></body></html>

instead of

https://www.bunq.com/?code=7d272be434a75933f40c13d56aef6c31496005b653074f7d6ac57029d9995d30
&state=594f5548-6dfb-4b02-8620-08e03a9469e6

Using postman to create an authorization request gives me the same response.

Am i doing something wrong?

    17 days later

    Hi Rachid,

    The response is a bunch of HTML, since you (as an "OAuth Provider") are supposed to redirect a user to the Authorization Request URL. Through a browser.

    They then accept the request by either scanning the QR-code with the bunq app (on pc) or opening the link with the bunq app directly (on mobile).

    If they accept the request, they'll be redirected to your webpage (redirect URL) and the code is returned to you as a query string. Like you expected.

    Then you are able to exchange that for an access_token, which you can use as an ApiKey to operate on the users behest.

    Ps. Still trying to figure out how to make this work in the Sandbox environment myself. But that should be the gest of it.

      Write a Reply...