500 Internal Errors using Google's URL shortener service API - google-apis-explorer

I'm trying to complete the JavaScript track on Codecademy, which requires an api key to access Google's URL shortener service. When I try to shorten, whether there or even when using the API's explorer page, I get errors.
POST https://www.googleapis.com/urlshortener/v1/url?key={YOUR_API_KEY}
{
"longUrl": "https://freecodecamp.org"
}
500 Internal Server Error
cache-control: private, max-age=0
content-encoding: gzip
content-length: 122
content-type: application/json; charset=UTF-8
date: Tue, 02 Jan 2018 18:13:54 GMT
expires: Tue, 02 Jan 2018 18:13:54 GMT
server: GSE
vary: Origin, X-Origin
{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "Backend Error"
}
],
"code": 500,
"message": "Backend Error"
}
}

Yeah... we're getting that too...
I believe Google Shortening service is currently down...

Related

Account linking error: "Can't parse the response. The response needs to be JSON format."

I am attempting account linking within 'Actions on Google'. Everything works until my OAuth provider responds to Google's request for tokens.
This is the JSON that is returned and appears to be properly formatted:
{"access_token":"edeaa27e-12b7-43a1-bc7c-e6bbf9af71c3","expires_in":5184000.0,"refresh_token":"4344383b-cf07-4d12-a5c2-44b6481f5f48","token_type":"Bearer"}
This is the error:
{ "#type": "type.googleapis.com/google.identity.accountlinking.type.AccountLinkingError", "errorReason": "Can't parse the response. The response needs to be JSON format.", "response": { ... }, "step": "AUTH_CODE_EXCHANGE" }
Details:
{
"insertId": "-hgv4mfb4b",
"jsonPayload": {
"#type": "type.googleapis.com/google.identity.accountlinking.type.AccountLinkingError",
"errorReason": "Can't parse the response. The response needs to be JSON format.",
"response": {
"status": 200,
"body": "{\"access_token\":\"cdd79134-316d-46ca-8d82-62fc7c35d905\",\"expires_in\":5184000.0,\"refresh_token\":\"fc63ceb3-0a8d-40ac-a1a3-a8cfab110bef\",\"token_type\":\"Bearer\"}"
},
"step": "AUTH_CODE_EXCHANGE"
},
"resource": {
"type": "assistant_action_project",
"labels": {
"project_id": "my-project"
}
},
"timestamp": "2021-07-30T23:15:28.221Z",
"severity": "ERROR",
"logName": "projects/my-project/logs/accountlinking-pa.googleapis.com%2Ferror",
"receiveTimestamp": "2021-07-30T23:15:28.676796217Z"
}
Here is the response from my OAuth provider via curl. This is what Google gets. It looks like properly formatted JSON.
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Cache-Control: private
Cache-Control: private
< Content-Type: application/json; charset=utf-8
Content-Type: application/json; charset=utf-8
< Vary: Accept
Vary: Accept
< Server: Microsoft-IIS/8.5
Server: Microsoft-IIS/8.5
< Request-Context: appId=cid-v1:f494398c-ac65-47c8-84be-65aea2c190a4
Request-Context: appId=cid-v1:f494398c-ac65-47c8-84be-65aea2c190a4
< X-HOST-nonce: 3eTaf/2/7riVVh24uAsUT+KHqcJPq0F2cw7C5ldMkMF4iH5rDbHQEgOp2OU9RaQFr/HjBBEpkKekcCxlmzek5g==
X-HOST-nonce: 3eTaf/2/7riVVh24uAsUT+KHqcJPq0F2cw7C5ldMkMF4iH5rDbHQEgOp2OU9RaQFr/HjBBEpkKekcCxlmzek5g==
< X-Powered-By: ServiceStack/4.040 Win32NT/.NET
X-Powered-By: ServiceStack/4.040 Win32NT/.NET
< X-AspNet-Version: 4.0.30319
X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
X-Powered-By: ASP.NET
< Date: Tue, 03 Aug 2021 03:17:00 GMT
Date: Tue, 03 Aug 2021 03:17:00 GMT
< Content-Length: 155
Content-Length: 155
< x-HOST-proxy: true
x-HOST-proxy: true
< Strict-Transport-Security: max-age=15768000
Strict-Transport-Security: max-age=15768000
{"access_token":"6cff16ee-3b3e-4ecf-9664-51515ede6cc8","expires_in":5184000.0,"refresh_token":"03725df6-8d4c-434a-ab36-adedb43b76d7","token_type":"Bearer"}
Google will not accept the 'expires_in' value above, because it includes a decimal. Not sure if this impacts all values with a decimal or just '.0', but the OAuth spec doesn't seem to specifically exclude such a value. Javascript converts any float with just a 0 after the decimal to a whole number. My issue was that the 3rd party OAuth provider was returning a string including a float that Google would not parse as JSON.

No enterprise was found for the given id

I have a valid Organization created at https://play.google.com/work. When I use the Organization ID available here as Enterprise Id for API calls avaialbe at https://developers.google.com/apis-explorer/#p/androidenterprise/v1/ , I am always getting below response.
404
cache-control: private, max-age=0 content-encoding: gzip content-length: 175 content-type: application/json; charset=UTF-8 date: Mon, 17 Jun 2019 07:47:15 GMT expires: Mon, 17 Jun 2019 07:47:15 GMT server: GSE vary: Origin, X-Origin
{ "error": { "errors": [ { "domain": "global", "reason": "notFound", "message": "No enterprise was found for the given id.", "locationType": "parameter", "location": "enterpriseId" } ], "code": 404, "message": "No enterprise was found for the given id." } }
Note: OAuth 2.0 Authorization is on.
This error could arise when the enterprise has already been deleted from Google console (https://play.google.com/work). You can navigate to above URL and in admin settings you can view your enterprise.

Getting 400 bad request reason:required from google cloud stoarge json api

I am attempting to upload a file (png in this this example) to google cloud storage but my request fails with the following 400 Bad Request response.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required"
}
],
"code": 400,
"message": "Required"
}
}
My POST request looks like this.
POST https://www.googleapis.com/upload/storage/v1/b/unit_tests/o?uploadType=media HTTP/1.1
Accept: application/json, text/json, text/x-json, text/javascript
Authorization: OAuth XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Content-Type: image/png
Host: www.googleapis.com
Transfer-Encoding: chunked
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
96DA5
�PNG
���
IHDR����������e�����sRGB�������gAMA����
�a��� pHYs�������o�d����IDATx^�|W��?o��������������,Y`I
*** FIDDLER: RawDisplay truncated at 128 characters. Right-click to disable truncation. ***
Per the documentation I've supplied the necessary paramters etc so I cannot see what is required that I am not providing.
You forgot to supply the name parameter in the URL. See the Simple upload documentation for more details.

ETag not updated in PATCH response

I'm testing my application that uses Drive API v2, and I noticed that I'm not
getting a new ETag in the response of a PATCH request.
I made some tests using the Google APIs Explorer. This is the PATCH request:
PATCH https://www.googleapis.com/drive/v2/files/0B-TenPiSMBplMTJnVlYxTEEwQ28?key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer ...
X-JavaScript-User-Agent: Google APIs Explorer
{
"title": "file.tmp"
}
And this is the beginning of the PATCH response that shows the ETag "EBHN0a_u6Vh64YcTBDNdNyfF7Hs/MTM4MTI2MTIxODY0MQ":
200 OK
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Encoding: gzip
Content-Length: 1019
Content-Type: application/json; charset=UTF-8
Date: Tue, 08 Oct 2013 19:46:36 GMT
Etag: "EBHN0a_u6Vh64YcTBDNdNyfF7Hs/MTM4MTI2MTIxODY0MQ"
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Pragma: no-cache
Server: GSE
{
"kind": "drive#file",
"id": "0B-TenPiSMBplMTJnVlYxTEEwQ28",
"etag": "\"EBHN0a_u6Vh64YcTBDNdNyfF7Hs/MTM4MTI2MTIxODY0MQ\"",
"selfLink": "https://content.googleapis.com/drive/v2/files/0B-TenPiSMBplMTJnVlYxTEEwQ28",
"webContentLink": "https://docs.google.com/uc?id=0B-TenPiSMBplMTJnVlYxTEEwQ28&export=download",
"alternateLink": "https://docs.google.com/file/d/0B-TenPiSMBplMTJnVlYxTEEwQ28/edit?usp=drivesdk",
"iconLink": "https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png",
"title": "file.tmp",
But if I do a GET request just after the PATCH:
GET https://www.googleapis.com/drive/v2/files/0B-TenPiSMBplMTJnVlYxTEEwQ28?key={YOUR_API_KEY}
Authorization: Bearer ...
X-JavaScript-User-Agent: Google APIs Explorer
In the response, I get an updated ETag ("EBHN0a_u6Vh64YcTBDNdNyfF7Hs/MTM4MTI2MTU5NjAyNg"):
200 OK
Cache-Control: private, max-age=0, must-revalidate, no-transform
Content-Encoding: gzip
Content-Length: 1021
Content-Type: application/json; charset=UTF-8
Date: Tue, 08 Oct 2013 19:48:44 GMT
Etag: "EBHN0a_u6Vh64YcTBDNdNyfF7Hs/MTM4MTI2MTU5NjAyNg"
Expires: Tue, 08 Oct 2013 19:48:44 GMT
Server: GSE
{
"kind": "drive#file",
"id": "0B-TenPiSMBplMTJnVlYxTEEwQ28",
"etag": "\"EBHN0a_u6Vh64YcTBDNdNyfF7Hs/MTM4MTI2MTU5NjAyNg\"",
"selfLink": "https://content.googleapis.com/drive/v2/files/0B-TenPiSMBplMTJnVlYxTEEwQ28",
"webContentLink": "https://docs.google.com/uc?id=0B-TenPiSMBplMTJnVlYxTEEwQ28&export=download",
"alternateLink": "https://docs.google.com/file/d/0B-TenPiSMBplMTJnVlYxTEEwQ28/edit?usp=drivesdk",
"iconLink": "https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png",
"title": "file.tmp",
Is this the intended behavior? I was expecting to get the updated ETag in the
PATCH response to avoid another roundtrip to the server. Notice also that I
experienced the same behavior using PUT instead of PATCH.
Sadly, Drive is somewhat asynchronous under the hood. Stuff like etags and some URLs are populated asynchronously after your PATCH has completed.

Valid JSON format to share text to a particular contact in Google Glass Mirror API?

I'm playing around with Google Mirror API and creating out some sample apps. Since I'm not an explorer I'm using Sturm's Mirror API.
I'd like to know the valid JSON format to share a piece of text to a particular Google Glass contact. I tried the following JSON in API explorer but got a 400 bad request error. Also is there a way to do the same through Google Glass Playground rather than API explorer?
{
'recipients': [
{
'acceptTypes': [
'text/plain'
],
'displayName': 'myglassapp',
'imageUrls': [
'https://myglassapp.appspot.com/images/welcome.jpg'
],
'id': 'babu_glass_app'
}
],
'kind': 'mirror#timelineItem',
'isDeleted': False,
'text' : 'Hello World',
}
Error:
400 Bad Request
- Hide headers -
cache-control: private, max-age=0
content-encoding: gzip
content-length: 118
content-type: application/json; charset=UTF-8
date: Thu, 30 May 2013 08:05:47 GMT
expires: Thu, 30 May 2013 08:05:47 GMT
server: GSE
{
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error"
}
],
"code": 400,
"message": "Parse Error"
}
}
Oops.. My bad. Python dict to JSON problem. False instead of false. And now the card is getting inserted.
{
'recipients': [
{
'acceptTypes': [
'text/plain'
],
'displayName': 'myglassapp',
'imageUrls': [
'https://myglassapp.appspot.com/images/welcome.jpg'
],
'id': 'babu_glass_app'
}
],
'kind': 'mirror#timelineItem',
'isDeleted': false,
'text' : 'Hello World',
}