Got a 'How do I' question? Join 'Ask a Trainer' Monday to Friday, 11am to 4pm ET for instant help and pro tips!

Getting 403 forbidden for access token in java

user383581
Rookie
0 Votes

String credentials = clientId + ":" + clientSecret;
String authHeader = "Basic " + Base64.getEncoder().encodeToString(credentials.getBytes());
System.out.println("authHeader==>" + authHeader);
// Create request URL
StringBuilder requestBuilder = new StringBuilder()
.append("https://authz.constantcontact.com/oauth2/default/v1/token").append("?code=")
.append(authCode).append("&redirect_uri=").append(redirectUri)
.append("&grant_type=authorization_code");
System.out.println("url==>" + requestBuilder.toString());

MultiValueMap<String, String> requestBody = new LinkedMultiValueMap<>();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
headers.set("Accept","application/json");
headers.set("Authorization", authHeader);
HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(requestBody, headers);
ResponseEntity<String> response = restTemplate.exchange(requestBuilder.toString(), HttpMethod.POST, entity, String.class);
System.out.println("response==>"+response);

1 REPLY 1
John__B
Employee
0 Votes

Hello user383581,

 

Thank you for reaching out to Constant Contact API Developer Support. My team is here to assist outside software developers with questions about building into Constant Contact's API.

 

It looks like we've already followed up with you directly via email, but I wanted to close the loop here as well. If you haven't received our reply, please let us know via email at webservices@constantcontact.com, and reference case number 31079547.

 

Please have a look and let us know if you have any other questions!

 

Regards,


John B.
API Support Specialist
Did I answer your question? If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.
Resources
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up