http://127.0.0.1:8080/Mailchimp/Access#access_token=^^^^^^^^^^^^^^^^^^^^^^^^^&expires_in=0
This is my mailchimp url , how to extract the access_token through java
and there another way to get the access token but here getting response message – Bad Request
URL siteUrl = new URL("https://login.mailchimp.com/oauth2/token");
HttpURLConnection conn = (HttpURLConnection) siteUrl.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
String content = "?grant_type=authorization_code&client_id=^^^^^^^^^^&client_secret=^^^^^^^^^^^^^^^^^^^^^^^^&code="+auth_code+"&redirect_uri=http://127.0.0.1:8080/Mailchimp/Access";
out.writeBytes(content);
System.out.println(content);
out.flush();
out.close();
System.out.println(conn.getResponseMessage());
The part after the # is called the “fragment” or “reference”. This is a basic way to extract the relevant part: