Randomly unable to verify credentials with API key but working with Username/password


(Askingmanu) #1

In the same environment, 2 computer out of 5 throw this error when clicking to “Verify credentials” while using a API key :

Error: Unexpected character encountered while parsing value: <. Path ‘’, line 0, position 0.
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path ‘’, line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Octopus.Client.Exceptions.OctopusExceptionFactory.CreateException(Int32 statusCode, String body)
at Octopus.Client.Exceptions.OctopusExceptionFactory.d__1.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at Octopus.Client.OctopusAsyncClient.<DispatchRequest>d__531.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Octopus.Client.OctopusAsyncClient.d__32`1.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Octopus.Client.OctopusAsyncClient.d__52.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Octopus.Client.OctopusAsyncClient.d__12.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Octopus.Client.OctopusAsyncClient.d__11.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Octopus.Manager.Tentacle.TentacleConfiguration.SetupWizard.TentacleSetupWizardModel.d__150.MoveNext() in Z:\buildAgent\workDir\c6c75a7c10de878b\source\Octopus.Manager.Tentacle\TentacleConfiguration\SetupWizard\TentacleSetupWizardModel.cs:line 460

When I try with Username/password, it’s working fine. I wonder why it’s not working for these computers. I have the same problem in other environment. Did I miss something?

Capture_d%E2%80%99e%CC%81cran__le_2018-11-19_a%CC%80_12_04_35


(Tom Williams) #2

Hi Manuel,

Thanks for reaching out, sorry to hear you have hit this issue while trying to configure your Tentacles.
This definitely is a strange issue, from the exception it looks like the Tentacle manager is receiving some sort of HTML instead of the expected JSON response.

  • Are you able to hit the Octopus server website from the problem tentacle machines?
  • Do you have any sort or proxy between the Server and Tentacles?

Something else that might be worth trying is running the following command from cmd on one of the Tentacles to see if we can capture the problematic response.

curl -X GET "http://<YourOctopusServer>/api/environments/all" -H "accept: application/json" -H "X-Octopus-ApiKey: <API-KEY>"

This simply tries to get environment data from the Octopus API using the API key.

Kind regards,
Tom W


(Askingmanu) #3

Hi Tom,
Thanks for your quick answer.
To answer your questions, first, I can reach the server, I can even install the tentacle with a username/password instead of API-KEY.

Second question’s answer, I have an IIS reverse proxy in front of my octopus server. I read in your white papers that Polling tentacles are not supported with a IIS reverse proxy (https://octopus.com/docs/administration/security/exposing-octopus/use-iis-as-reverse-proxy), but it still working for almost every clients. Example, I have currently 5 computers in the same network with the same Windows Image, 3 out of 5 is working properly with Polling tentacles using API-KEY, the 2 other ones working only with credentials as Polling tentacles, and I don’t know which is the breaking parameter in that case, very weird.

Finally, I ran the curl command you asked for, and unfortunately that returns the right informations, no HTML :frowning: … Here’s the output :

Thanks for your help!


(Tom Williams) #4

Hi Manuel,

Thanks for trying that out. This is a very strange issue, if you don’t mind I would like to get your help to investigate it a bit further.
Are you able to install Fiddler (you can download here)? I want to try and capture the network traffic and see if we can see what is going on.
Once you have Fiddler installed and running, you can try setting up another polling tentacle, we dont need to complete the setup, we just need to capture what happens when you attempt to authenticate with the API key.
When configuring the polling tentacle you will need to specify a proxy, this will be the fiddler proxy that allows us to capture the traffic, the proxy server should be set to 127.0.0.1 with the port 8888

Hopefully you are able to see an error in fiddler (should be displayed in red) when you authenticate. If you are able to send through the raw response, hopefully that will provide an indication of what is going on.

Kind regards,
Tom W


(Askingmanu) #5

Hi Tom,
Sorry for the delay.
Here’s the Fiddler output :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request</h2>
<hr><p>HTTP Error 400. The request is badly formed.</p>
</BODY></HTML>

(Tom Williams) #6

Hi Manuel,
It looks like something is happening to the Request.
Are you able to run it again and also capture the body of the request so we can make sure it is indeed valid?

Kind regards,
Tom W


(Askingmanu) #7

Hi Tom, I’ve obfuscated a little bit but here’s the body of the request :

GET http://octopus.mydomain.net/api HTTP/1.1

Accept: application/json

X-Octopus-ApiKey: API-90QO9XXXXXXXXXXXXXXXXXX7SO

User-Agent: OctopusClient-dotnet/4.33.1

Host: octopus.mydomain.net

Connection: Keep-Alive


(system) #8

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.