Google API malformed or illegal request - oauth-2.0

I issue the following request:
URI:
https://accounts.google.com/o/oauth2/token
HEADERS:
content-length 307
content-type application/x-www-form-urlencoded
BODY:
client_id=8633333333-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com&client_secret=dsfhosgoisdflkjsdfjlkssd&code=4%2skjsdhfsnfklfsjlkfsjlsfdcmMKts1jHnbrAAGls&grant_type=authorization_code&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive
The response I get is:
400 <!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 400 (Bad Request)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>400.</b> <ins>ThatΓÇÖs an error.</ins>
<p>Your client has issued a malformed or illegal request. <ins>ThatΓÇÖs all we know.</ins>
Please can anybody help me point to the mistake in the https request.
Thanks,
Milind

Thank you DalmTo. I tried that but that did not solve the problem. Then after carefully looking at each and every part of the request I saw that my socket library was sending the HTTP method as "GET" even though I was giving a body. Once I forced it to "POST" it worked!

Related

Google sheet get api response limits

Can somebody please help me in finding official limits of Google Spreadsheet api "RESPONSE".
Is it size based or num of cell based. I have to pull Grid data for number of columns from a quite big google sheet(30*57000).
But it fails to respond if I pull range of more then 18 columns in single request.
The error I receives
com.google.api.client.googleapis.json.GoogleJsonResponseException: 502 Bad Gateway
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 502 (Server Error)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>502.</b> <ins>That’s an error.</ins>
<p>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds. <ins>That’s all we know.</ins>`
Get request looks like:
{fields=sheets.data.rowData.values.effectiveFormat, ranges=[Sheet1!A2:A, Sheet1!M2:M, Sheet1!N2:N, Sheet1!O2:O, Sheet1!R2:R, Sheet1!S2:S, Sheet1!T2:T, Sheet1!U2:U, Sheet1!V2:V, Sheet1!X2:X, Sheet1!Y2:Y, Sheet1!Z2:Z, Sheet1!AC2:AC, Sheet1!AD2:AD, Sheet1!AE2:AE, Sheet1!AF2:AF, Sheet1!AG2:AG, Sheet1!AH2:AH, Sheet1!AI2:AI, Sheet1!AJ2:AJ], spreadsheetId=1_qVz-XXXXXXXXXXXXXXXXrXXXXXXXXXXXXXXXX}
Based on your example I was able to replicate the behaviour. That 502 appears when getting huge ranges while including the grid data in the response. In order to prevent this issue the docs lists «For large spreadsheets, it is recommended to retrieve only the specific fields of the spreadsheet that you want». Based on that approach, I strongly suggest you to get only the relevant ranges for the operation at hand. If you really need to get 18 columns (each with 57,457 rows), then you should spread your requests in several batches. Then you could join the responses so you could have a big array to interact with. Please ask me to clarify any point if needed.

Facing intermittent 404 issue when calling Rails API

I have banged my head on this for 2 days now and i dint find any luck yet. Looking for help on this.
The issue:
Front End makes 10 similar XHR requests ( for different users ) to my Rails API and few of the requests randomly fails with 404 status code.
My Observations:
If i make the same request again, It passes.
I dont see any trace of 404 requests even hitting my server ( using logs ).
I do see different response headers for 200 and 404 ( mentioned below ) and i see cowboy ( https://github.com/heroku/cowboyku, https://github.com/heroku/vegur) server for 404 requests. I run my rails production with thin web server.
My theory is that, As few of my requests are not able to hit my thin server, they are getting 404. Now, the confusion is, Why is it hitting cowboy
200 Status Code
404 Status Code
[EDITS]
response payload for 404 errors is something like below.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>No such app</title>
<style media="screen">
html,body,iframe {
margin: 0;
padding: 0;
}
html,body {
height: 100%;
overflow: hidden;
}
iframe {
width: 100%;
height: 100%;
border: 0;
}
</style>
</head>
<body>
<iframe src="//www.herokucdn.com/error-pages/no-such-app.html"></iframe>
</body>
</html>

Rails HTTParty same 404 response in 2 different APIs

My Rails app just started to return 404 errors last Thursday on our Staging server, and I'm trying to figure out why. We hit 2 completely different APIs in our app, and they have been working for months. All of a sudden, we got 404 errors all morning, and without any changes, they work again.
We are using HTTParty to hit these external APIs. The response for both APIs are exactly the same, and it is a generic html template for 404 errors:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>404 - File or directory not found.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>404 - File or directory not found.</h2>
<h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
</fieldset></div>
</div>
</body>
</html>
My initial guess is that we somehow hit the wrong endpoint for both, which is unlikely because we never changed anything and they have been working for months. But I tried to hit the wrong endpoint in one of the external API anyway, and this is the response I got:
<html>
<head><title>404 Not Found</title></head>
<body bgcolor=\"white\">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
I noticed right away that these two 404 html templates are different, and at this point, I'm not sure what really happened. Since we got the same exact 404 response for both APIs, my hunch is that something is wrong on our side, not theirs, but I'm not 100% sure. I would really appreciate any help! Thanks!

redirect_uri not working in soundcloud

I had used the code of callback.html as show in "https://developers.soundcloud.com/docs/api/sdks#javascript" and saved
that callback.html file in my server
("http://www.openxcelltechnolabs.info/phonegap/sound/callback.html").
Callback.html
<!DOCTYPE html>
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/JavaScript" src="http://connect.soundcloud.com/sdk.js"></script>
<title>Connect with SoundCloud</title>
</head>
<body onload="window.opener(window.opener.SC.connectCallback, 1);">
<b style="width: 100%; text-align: center;">This popup should automatically close in a few seconds</b>
</body>
</html>
here is my details
client_id: "df20e6893cd18c616f9277adb284f0c8",
redirect_uri: "http://www.openxcelltechnolabs.info/phonegap/sound/callback.html"
When i run my app i am getting authentication window of sound cloud. But
after that when i click connect after entering my credentials it shows "This popup should automatically close in a few seconds" but its not getting closed.
And i had also add url in app setting.
Please help me out. Thanks in advance.

Why does this webpage display differently when URL forwarded?

I have a simple Google maps web application I'm working on. I have purchased a domain name for the application (http://www.jcunav.com), which during my testing, is designed to simply forward to a page which is hosted on my another domain name of mine (http://www.codeemporium.com/experiments/map5.html). Testing on my Android Nexus S, I am noticing strange behaviour however - if I visit http://www.codeemporium.com/experiments/map5.html directly, then the app displays as intended - the map is the size I want and clicking the "About" link brings up a dialog the size I want. If I visit http://www.jcunav.com however (which, keep in mind, simply forwards to http://www.codeemporium.com/experiments/map5.html), the map displays at what looks like a more zoomed out level, and pressing the "About" link at the bottom of the page shows a dialog box which also appears more zoomed out. My question is, what could be causing this to occur, given that all http://www.jcunav.com is doing is forwarding to http://www.codeemporium.com/experiments/map5.html...
Are you certain you aren't frame-forwarding? I examined the page in firebug for each of the links you provided and it appears to me that you are frame-forwarding the URL. This results in your target page being 'wrapped' in a frame when presented to the end user. Odds are high that this is why it is not working for you.
Here is a somewhat lossy version of what is in the forwarded page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>JCU Nav</title>
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</head>
<frameset frameborder="0" framespacing="0" border="0" rows="100%,*">
<frame name="MYTOPFRAME" src="http://www.codeemporium.com/experiments/map5.html" noresize>
-- snip --
</frameset>
</html>
Notice the frame tag:
<frameset frameborder="0" framespacing="0" border="0" rows="100%,*">
<frame name="MYTOPFRAME" src="http://www.codeemporium.com/experiments/map5.html" noresize>
This is what happens when you frame forward.
Since your sizing relies on additions to the HTML tag:
<html class="ui-mobile landscape min-width-320px min-width-480px min-width-768px min-width-1024px">
They do not work in the frame-forwarded version because they are nested inside the frame and not on the root page.
That's because http://www.jcunav.com is not forwarding to http://www.codeemporium.com/experiments/map5.html, it is loading it into a frame:
C:\Documents and Settings\blah>wget -S -O - http://www.jcunav.com/
--01:05:21-- http://www.jcunav.com/
=> `-'
Resolving www.jcunav.com... 66.150.161.141, 69.25.27.173, 63.251.171.80, ...
Connecting to www.jcunav.com|66.150.161.141|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Date: Sun, 01 May 2011 05:01:11 GMT
Server: Apache/2.0.49 (Unix) PHP/4.3.9
X-Powered-By: PHP/4.3.9
Content-Length: 823
Connection: close
Content-Type: text/html; charset=ISO-8859-1
Length: 823 [text/html]
0% [ ] 0 --.--K/s <
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>JCU Nav</title>
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</head>
<frameset frameborder="0" framespacing="0" border="0" rows="100%,*">
<frame name="MYTOPFRAME" src="http://www.codeemporium.com/experiments/map5.html" noresize>
<noframes>
<body>
<h1>JCU Nav</h1>
<br>
<br>
<br>
Click here to enter <a href="http://www.codeemporium.com/experiments/map5.html">http://www.codeemporium.com/e
xperiments/map5.html</a>
<hr>
| Domain Name Registration and Domain Name Forwarding by <a href="http://www.mydomain.com">mydomain.com - Register your
domain name</a>
</body>
</noframes>
</frameset>
</html>
You'll need to actually change that frame set to do the right thing.

Resources