I believe I've followed the docs, but am getting a 400 status code when trying to get an access token. I've created the API code and call the following URL to get the auth code:
// https://api.cc.email/v3/idfed?client_id=22c<redacted>2c3b&redirect_uri=https%3A%2F%2Flocalhost&response_type=code&scope=account_read+account_update+contact_data
private HashMap< String , String > headersMap = new HashMap<>();
public static void main( String[] args ) throws IOException {
ConstantContactUtilities constantContactUtilities = new ConstantContactUtilities();
constantContactUtilities.getAuthCodeFromAccessTokenAndRefreshToken();
}
public ConstantContactUtilities() {
// apiKey and clientId are the same field. Stupid ConstantContact uses both terms for the same thing
String apiKey = "22c<redacted>2c3b";
String clientSecret = "RPd<redacted>jCQ";
String credentials = apiKey + ":" + clientSecret;
String authorization = "Basic " + Base64.getEncoder().encodeToString(credentials.getBytes());
headersMap.put( "Authorization" , authorization );
}
public void getAuthCodeFromAccessTokenAndRefreshToken() throws IOException {
String authCode = "Bo090<redacted>8NQAEt";
HttpUtilities httpUtilities = HttpUtilities.getInstance();
String url = "https://idfed.constantcontact.com/as/token.oauth2?code=" + authCode +
"&redirect_uri=https://localhost&grant_type=authorization_code";
HttpResponse httpResponse = httpUtilities.doPost( url , headersMap , new HashMap< String , String >() );
System.out.println( httpResponse.getStatusLine() ); <-- 400 status code
}
}
What am I doing wrong?
Hello Todd,
It looks like we already reached out to you via email regarding this issue to request some additional information in order to assist in troubleshooting. If you still need assistance with this, please let us know!
Announcements
Join our list to be notified of new features and updates to our V3 API.
Sign Up