The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

No credentials available for BASIC 'api.constantcontact.com'@api.constantcontact.com:443

Highlighted
Occasional Participant

No credentials available for BASIC 'api.constantcontact.com'@api.constantcontact.com:443

Hello,


I'm trying to update our application to use Basic authentication over https.


Two changes have been made:


 1.     URI looks like this now: "https://api.constantcontact.com/ws/customers/ourcompany/activities"


 2.     HttpClient API call has been change to use 'AuthPolicy.BASIC'.


Also, according to this resource: http://hc.apache.org/httpclient-3.x/sslguide.html, with HttpClient, we don't need to do anything extra in order  to use SSL communications.


My problem is that, I'm getting 401 error with the following message:


Jun 20, 2009 12:12:10 AM org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge

INFO: No credentials available for BASIC 'api.constantcontact.com'@api.constantcontact.com:443


Could, please, anybody help me to resolve this issue.


 


Thanks in advance,


Mike

5 REPLIES 5
Highlighted
Moderator

This response indicates that

This response indicates that the Basic Authentication is not being set corretly in your HttpClient class.  I would refer to the documentation on that class on how to implement Basic Authentication over a secury connection (https).  Have you tried running the test case they suggested for ensuring your Apache server is set up correctly?

Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Occasional Participant

No, I have not ran that

No, I have not ran that test.


Could you please point me where I can find it?

Highlighted
Occasional Participant

still having problems

Dave,


I can't find any other settings for HttpClient in order to set it for basic authentication.


Would it be helpfull if I paste my code for your review?

Highlighted
Occasional Participant

No credentials available for BASIC 'api.constantcontact.com'@ap

Dave, I'm not getting anywhere and time is running out.


I'm posting trimmed down version of my code. Could you please take a look and see what is wrong.




public class ConstantContactActivityUpload {



    public void upload(List<ConstantContactUploadInfo> infoList, int listKey) throws IOException {   

    UsernamePasswordCredentials credentials = setCredentials();

    HttpClient httpClient = initialSetUp(credentials);

    AuthDetails authDetails = extractAuthDetails();



        RequestEntity requestEntity ...



    String url = "https://api.constantcontact.com/ws/customers/ourcompany/activities";

    this.postToServer(httpClient, requestEntity, url, uploadedValues.toString());

    }



    private HttpClient initialSetUp(UsernamePasswordCredentials credentials) {

        HostConfiguration hostConfiguration = new HostConfiguration();

        hostConfiguration.setHost("api.constantcontact.com");



        AuthScope authScope = new AuthScope("api.constantcontact.com", 80, "api.constantcontact.com");



        AuthPolicy.registerAuthScheme("Basic", BasicScheme.class);



        HttpClient httpClient = new HttpClient();



        List<String> list = new ArrayList<String>();

        list.add(AuthPolicy.BASIC);

        httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, list);

        httpClient.getState().setCredentials(authScope, credentials);

        return httpClient;

    }



    private void postToServer(HttpClient client,  RequestEntity requestEntity, String url, String uploadedValues) throws HttpException, IOException {

        PostMethod httpPost = new PostMethod(url);

        httpPost.setRequestEntity(requestEntity);

            client.executeMethod(httpPost);

    }



    private UsernamePasswordCredentials setCredentials() {...} 

    protected AuthDetails extractAuthDetails() {...}

}

Highlighted
New Member

You need to update your port in your AuthScope

Change the port fom 80 to 443 or to a negative number or to AuthScope.ANY_PORT.

Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured