Skip to content

HttpClient tries to assemble incorrect header, can't connect #275

Open
@ddrennan-dch

Description

@ddrennan-dch

Seems to be the same as #238 .

Basically, the HttpClient tries to construct the Authorization header as follows:

  1. Add colon to the end of the Intercom token
  2. Encode that in base64
  3. Add it to a Basic header

So it ends up being

Authorization:Basic [newly encoded token value]

I believe Basic is used when you want to send a username/password, but since we just have a token, it should be Bearer. Also the colon is not needed, the token value should be used as-is.

Version info

  • intercom-java version: 2.7.1
  • Java version: 1.7, 1.8

Expected behavior

API connects to Intercom and pulls data.

Actual behavior

HttpClient fails to make connection due to bad header.

Steps to reproduce

Intercom.setToken("token");
CompanyCollection companies = Company.list();

Logs

SEVERE: Servlet.service() for servlet [datacenterhawk] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: Illegal character(s) in message header value: Basic W0JANzAwOTFhYTI6
] with root cause
java.lang.IllegalArgumentException: Illegal character(s) in message header value: Basic W0JANzAwOTFhYTI6

	at sun.net.www.protocol.http.HttpURLConnection.checkMessageHeader(HttpURLConnection.java:541)
	at sun.net.www.protocol.http.HttpURLConnection.isExternalMessageHeaderAllowed(HttpURLConnection.java:492)
	at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3075)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestProperty(HttpsURLConnectionImpl.java:325)
	at io.intercom.api.HttpClient.applyHeaders(HttpClient.java:224)
	at io.intercom.api.HttpClient.initializeConnection(HttpClient.java:145)
	at io.intercom.api.HttpClient.executeHttpMethod(HttpClient.java:106)
	at io.intercom.api.HttpClient.get(HttpClient.java:86)
	at io.intercom.api.HttpClient.get(HttpClient.java:82)
	at io.intercom.api.DataResource.list(DataResource.java:66)
	at io.intercom.api.Company.list(Company.java:59)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions