Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ddrennan-dch opened this issue Feb 10, 2020 · 0 comments · May be fixed by #276
Open

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

ddrennan-dch opened this issue Feb 10, 2020 · 0 comments · May be fixed by #276

Comments

@ddrennan-dch
Copy link

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant