Unexpected response Content-Type text/html
DotNetOpenAuth.DLL!DotNetOpenAuth.Messaging.ErrorUtilities.VerifyProtocol(bool condition, string message, object[] args) Line 237 C#
DotNetOpenAuth.DLL!DotNetOpenAuth.Messaging.ErrorUtilities.ThrowProtocol(string message, object[] args) Line 257 C#
DotNetOpenAuth.DLL!DotNetOpenAuth.OAuth2.ChannelElements.OAuth2ClientChannel.ReadFromResponseCore(DotNetOpenAuth.Messaging.IncomingWebResponse response) Line 67 + 0x1a4 bytes C#
DotNetOpenAuth.DLL!DotNetOpenAuth.Messaging.Channel.RequestCore(DotNetOpenAuth.Messaging.IDirectedProtocolMessage request) Line 659 + 0xe bytes C#
DotNetOpenAuth.DLL!DotNetOpenAuth.Messaging.Channel.Request(DotNetOpenAuth.Messaging.IDirectedProtocolMessage requestMessage) Line 477 + 0xe bytes C#
DotNetOpenAuth.DLL!DotNetOpenAuth.OAuth2.ClientBase.UpdateAuthorizationWithResponse(DotNetOpenAuth.OAuth2.IAuthorizationState authorizationState, DotNetOpenAuth.OAuth2.Messages.EndUserAuthorizationSuccessAuthCodeResponse authorizationSuccess) Line 204 + 0x19 bytes C#
DotNetOpenAuth.DLL!DotNetOpenAuth.OAuth2.WebServerClient.ProcessUserAuthorization(DotNetOpenAuth.Messaging.HttpRequestInfo request) Line 118 + 0xf bytes C#
By the looks of it, either the server is buggy, or it's running an incompatible version of OAuth 2.0 (there are only 13 drafts of that unfinalized spec out there in use today). This is one reason to not use OAuth 2.0 in production until it's finalized.
Related
The mentioned error comes calling an API behind a firewall but and I am trying to access the API from an EngineYard instance. The EngineYard instances IPs are white listed in their firewall.
client = Savon.client(wsdl: "https://amagentostore.com/api/v2_soap?wsdl", read_timeout: 300, follow_redirects: true)
products = client.
call(:dcapimodule_product_list, message: { session_id: session_id, additional_attributes: #additional_attributes }).
body[:dcapimodule_product_list_response][:products][:item]
I get the following error
File "/usr/lib64/ruby/2.3.0/openssl/buffering.rb" line 178 in sysread_nonblock
File "/usr/lib64/ruby/2.3.0/openssl/buffering.rb" line 178 in read_nonblock
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/excon-0.59.0/lib/excon/socket.rb" line 46 in readline
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/excon-0.59.0/lib/excon/response.rb" line 63 in parse
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/excon-0.59.0/lib/excon/middlewares/response_parser.rb" line 7 in response_call
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/excon-0.59.0/lib/excon/connection.rb" line 389 in response
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/excon-0.59.0/lib/excon/connection.rb" line 253 in request
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/excon-0.59.0/lib/excon/connection.rb" line 314 in post
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/httpi-2.4.2/lib/httpi/adapter/excon.rb" line 25 in request
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/httpi-2.4.2/lib/httpi.rb" line 161 in request
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/httpi-2.4.2/lib/httpi.rb" line 133 in post
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/savon-2.11.2/lib/savon/operation.rb" line 94 in block in call_with_logging
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/savon-2.11.2/lib/savon/request_logger.rb" line 12 in log
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/savon-2.11.2/lib/savon/operation.rb" line 94 in call_with_logging
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/savon-2.11.2/lib/savon/operation.rb" line 54 in call
File "/data/feed_champion/shared/bundled_gems/ruby/2.3.0/gems/savon-2.11.2/lib/savon/client.rb" line 36 in call
File "/data/feed_champion/releases/20180110042633/app/services/magento/product.rb" line 84 in products
Any idea?
The problem was #additional_attributes was being nil while the WSDL was expecting an array.
I'm using RestTemplate to make the GET call to asana's REST Api.
By using postmen when i'm calling:
https://app.asana.com/api/1.0/events?resource=PROJECT_ID
I'm getting a message and a sync token ( this is the same case when the sync token is too old and needs to be renewed ).
By using the RestTemplate, when the sync token is too old \ its the first call i'm making and I need a sync token, I'm getting a 412 response "Prediction Faild".
This happens also in postman, but i'm getting along with the "error" message the new sync token.
With the RestTemplate all i'm getting is this error:
Aug 06, 2015 3:56:55 PM org.springframework.web.client.RestTemplate handleResponseError
WARNING: GET request foPROJECT_ID21650756795165" resulted in 412 (Precondition Failed); invoking error handler
Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 412 Precondition Failed
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:90)
at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:494)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:451)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:409)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:385)
at availo.worker.asana.MainTask.getEvents(MainTask.java:86)
at availo.worker.asana.MainTask.getProjects(MainTask.java:76)
at availo.worker.asana.MainTask.main(MainTask.java:115)
Any suggestions?
Thanks!
This worked for me. It lets you read the message that comes with the error:
restTemplate.setErrorHandler(new DefaultResponseErrorHandler(){
protected boolean hasError(HttpStatus statusCode) {
return false;
}});
When first subscribing to Events on a resource you will receive a 412 Precondition Failed response code due to the fact that there is no sync token established yet. You should extract that sync token and use it in your next request to begin receiving events.
It looks like RestTemplate is invoking an error handler due to the 412 response code, which is understandable as a 412 is an error code.
If you can override DefaultResponseErrorHandler.handleError(), check that the response is a 412, then extract the sync token you could pass that in your next request to get events on the resource.
Another option is to use our Java client library, which should handle all of this for you.
This is what it might look like using our client:
System.out.println("Watching for events on project: " + project.name);
for (Event event : client.events.get(project.id)) {
System.out.println("User: " + event.user.name + "\nAction: " + event.action + "\nResource: " + event.resource);
}
I'm trying to upgrade the DotNetOpenAuth verson to 4.2.2.13055, in the Google dotnet client library.
So I downloaded the latest dlls - DotNetOpenAuth.Core, DotNetOpenAuth.OAuth2, etc. (we still don't work with NuGet).
I made a small change (changed the way I construct NativeApplcationClient with client_id and client_secret) to support the new version.
Then, I tried to run a sample we have in our samples repository (e.g. https://code.google.com/p/google-api-dotnet-client/source/browse/Tasks.SimpleOAuth2/Program.cs?repo=samples), and I got a bad request error, as following:
DotNetOpenAuth.Messaging.ProtocolException: Error occurred while sending a direct message or getting the response. --->
System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions opt
ions)
--- End of inner exception stack trace ---
at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions opt
ions)
at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request)
at DotNetOpenAuth.Messaging.Channel.GetDirectResponse(HttpWebRequest webRequest)
at DotNetOpenAuth.Messaging.Channel.RequestCore(IDirectedProtocolMessage request)
at DotNetOpenAuth.Messaging.Channel.Request(IDirectedProtocolMessage requestMessage)
at DotNetOpenAuth.OAuth2.ClientBase.UpdateAuthorizationWithResponse(IAuthorizationState authorizationState, EndUserAu
thorizationSuccessAuthCodeResponse authorizationSuccess)
at DotNetOpenAuth.OAuth2.UserAgentClient.ProcessUserAuthorization(IAuthorizationState authorizationState, IDirectedPr
otocolMessage response)
at DotNetOpenAuth.OAuth2.UserAgentClient.ProcessUserAuthorization(Uri actualRedirectUrl, IAuthorizationState authoriz
ationState)
at Google.Apis.Authentication.OAuth2.DotNetOpenAuth.NativeApplicationClient.ProcessUserAuthorization(String authCode,
IAuthorizationState authorizationState) in c:\code.google.com\google-api-dotnet-client\default_oauth2\Src\GoogleApis.Au
thentication.OAuth2\DotNetOpenAuth\NativeApplicationClient.cs:line 102
at Google.Apis.Samples.TasksOAuth2.Program.GetAuthorization(NativeApplicationClient arg) in c:\code.google.com\google
-api-dotnet-client\samples_oauth2\Tasks.SimpleOAuth2\Program.cs:line 73
at Google.Apis.Authentication.OAuth2.OAuth2Authenticator`1.LoadAccessToken() in c:\code.google.com\google-api-dotnet-
client\default_oauth2\Src\GoogleApis.Authentication.OAuth2\OAuth2Authenticator.cs:line 124
I noticed also that there is a different in the second request (in exchanging the code with a token): Authorization header was added to the request, and the body was missing my client_id and client_secret.
Similar code worked on old version - 4.0.0.11165,
Am I missing something?
I wonder if the problem is that the newer DNOA version supports putting client credentials in the HTTP header by default. If you create your Client class, passing in a different client credential provider into the constructor, it may work for you.
To change the behavior from using the HTTP Authorization header back to passing client credentials in the POST entity, instantiate your ClientBase-derived class passing in this as a parameter to the constructor:
ClientCredentialApplicator.PostParameter(clientSecret)
I am quite new to the concept of ipython and twython .However i want to retrieve some data using twitter.search query .But when i use it it gives me the following error
In [3]: search_results = twitter.search(q="#india", rpp="50")
---------------------------------------------------------------------------
TwythonError Traceback (most recent call last)
/home/vishal/<ipython-input-3-241f789b11cc> in <module>()
----> 1 search_results = twitter.search(q="#india", rpp="50")
/usr/local/lib/python2.7/dist-packages/twython-2.5.5-py2.7.egg/twython/twython.pyc in search(self, **kwargs)
365 """
366
--> 367 return self.get('https://api.twitter.com/1.1/search/tweets.json', params=kwargs)
368
369 def searchGen(self, search_query, **kwargs):
/usr/local/lib/python2.7/dist-packages/twython-2.5.5-py2.7.egg/twython/twython.pyc in get(self, endpoint, params, version)
236
237 def get(self, endpoint, params=None, version='1.1'):
--> 238 return self.request(endpoint, params=params, version=version)
239
240 def post(self, endpoint, params=None, files=None, version='1.1'):
/usr/local/lib/python2.7/dist-packages/twython-2.5.5-py2.7.egg/twython/twython.pyc in request(self, endpoint, method, params, files, version)
231 url = '%s/%s.json' % (self.api_url % version, endpoint)
232
--> 233 content = self._request(url, method=method, params=params, files=files, api_call=url)
234
235 return content
/usr/local/lib/python2.7/dist-packages/twython-2.5.5-py2.7.egg/twython/twython.pyc in _request(self, url, method, params, files, api_call)
208 raise exceptionType(error_msg,
209 error_code=response.status_code,
--> 210 retry_after=response.headers.get('retry-after'))
211
212 # if we have a json error here, then it's not an official TwitterAPI error
TwythonError: 'Bad Request: The request was invalid. An accompanying error message will explain why. This is the status code will be returned during rate limiting. -- An error occurred processing your request
what could be the issue.
Does it requires authentication
Thanks
Twitter API v1 search didn't not need authentication, however; the Twitter search API now requires authentication in v1.1. (https://dev.twitter.com/docs/api/1.1/get/search/tweets)
Thanks for using Twython!
For me this code works:
from twython import Twython
twitter = Twython()
search_results = twitter.search(q="#india", rpp="50")
for tweet in search_results["results"]:
print "Tweet from#%s Date: %s" % (tweet['from_user'].encode('utf-8'),tweet['created_at'])
print tweet['text'].encode('utf-8'),"\n"
I'm trying to build a websocket server on Delphi6 using the draft hixie-76 and i have a problem with the handshake.
The md5 fingerprint i get with the three parts does not seem to be correct when i try it, but when i use the same algorythm with the exemple given in the protocole spec i get the good md5 response...
I'm processing like this, transform the number found in key1 divided by the number of spaces in a 32 bits word, same with key2 and finally adding the last 8 bytes (key3) to get a 128 bits string which i use as md5 entry.
using 155712099, 173347027 for key1 and key2 and 'Tm[K T2u' for key3, i get the correct md5 fingerprint and so i don't understand why this algo won't give a correct fingerprint to the client
here is an exemple of what i receive :
GET / HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: localhost:8018
Origin: null
Sec-WebSocket-Key1: 4 102(2 6U 2 3 18
Sec-WebSocket-Key2: 69V86`6t)e 0 2 42
M]Rzÿõ&
and the handshake i give in response
HTTP/1.1 101 WebSocket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
Sec-WebSocket-Origin: null
Sec-WebSocket-Location: ws://localhost:8018/
µ&Mq˜8èõÙZÙ,hœi
Maybye there's another probleme with my response but it reall seems that i have a problem with my md5 fingerprint.
Does anyone see where my mistake is??
Thanks in advance for your help
Update
I have seen this unit but unless i'm very bad at reading, the handshake part of this class does not calculate any md5 sum, i think it uses an older version of the protocol and not the current (76)
When i look at the following code i see that the answer is written without any md5 response.
` try
// Read request headers
HandshakeRequest := TWebSocketRequest.Create(ServerConnection);
// Send response headers
ServerConnection.WriteLn('HTTP/1.1 101 Web Socket Protocol Handshake');
ServerConnection.WriteLn('Upgrade: WebSocket');
ServerConnection.WriteLn('Connection: Upgrade');
ServerConnection.WriteLn('WebSocket-Origin: ' + HandshakeRequest.Origin);
ServerConnection.WriteLn('WebSocket-Location: ws://' + HandshakeRequest.Host + '/');
// End handshake
ServerConnection.WriteLn;
ServerConnection.WriteLn;
HandshakeResponseSent := True;
except
on E: TWebSocketHandshakeException do
begin
// Close the connection if the handshake failed
ServerConnection.Disconnect;
end;`
Thanks again
Update 2011 04 14
I have finally found where the problem was...
i was building my response like that :
resp := [...] +'Sec-WebSocket-Origin: '+ origin + #13#10 +
#13#10#13#10 +
md5response;
so there was 3 0x0D 0x0A instead of 2 before the md5 fingerprint ...
Since i cannot answer my own question i won't be able to mark it solve but it is! :)
There exists a websocket class in google code for Delphi that might give you the answer:
http://code.google.com/p/delphiws/source/browse/trunk/source/uWebSocket.pas?r=4