Premium requests against Foursquare API fail with 429 and "quota_exceeded" error - foursquare

I have a problem making "premium" requests against Foursquare API. There's an app that has been doing requests for a while now, but ceased to do so a few days ago.
Here's how it looks like on a sample venue (from API explorer):
In [47]: requests.get('https://api.foursquare.com/v2/venues/49eeaf08f964a52078681fe3', params={'client_id': settings.FOURSQUARE_CLIENT_ID, 'client_secret': settings.FOURSQUARE_CLIENT_SECRET, 'v': '20180611'})
2018-06-11 14:37:03,221:DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.foursquare.com
2018-06-11 14:37:03,616:DEBUG:urllib3.connectionpool:https://api.foursquare.com:443 "GET /v2/venues/49eeaf08f964a52078681fe3?client_secret=<SNIP>&client_id=<SNIP>&v=20180611 HTTP/1.1" 429 134
Out[47]: <Response [429]>
In [49]: dict(_47.headers)
Out[49]:
{'Accept-Ranges': 'bytes',
'Access-Control-Allow-Origin': '*',
'Connection': 'keep-alive',
'Content-Length': '134',
'Content-Type': 'application/json; charset=utf-8',
'Date': 'Mon, 11 Jun 2018 14:37:03 GMT',
'Server': 'nginx',
'Tracer-Time': '1',
'Via': '1.1 varnish',
'X-Cache': 'MISS',
'X-Cache-Hits': '0',
'X-RateLimit-Limit': '0',
'X-RateLimit-Path': '/v2/venues/X',
'X-RateLimit-Remaining': '0',
'X-Served-By': 'cache-hhn1536-HHN'}
In [50]: _47.json()
Out[50]:
{u'meta': {u'code': 429,
u'errorDetail': u'Quota exceeded',
u'errorType': u'quota_exceeded',
u'requestId': u'5b1e890f6a60717ee10bf7cd'},
u'response': {}}
The response is clearly related to rate limits, but it doesn't follow the description outlined in https://foursquare.com/dev/overview/ratelimits or https://developer.foursquare.com/docs/api/troubleshooting/rate-limits. More importantly, it shows 'X-RateLimit-Limit': '0' suggesting there's either no limit or that it's entirely forbidden.
User-based access with tokens created by users of our applications fail in the same manner.
User-based access with a token copied from API explorer surprisingly works (but displays the same 'X-RateLimit-Limit': '0' as the failing response above):
In [56]: requests.get('https://api.foursquare.com/v2/venues/49eeaf08f964a52078681fe3', params={'oauth_token': sample_oauth_token, 'v': '20180611'})
2018-06-11 14:35:00,417:DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.foursquare.com
2018-06-11 14:35:01,066:DEBUG:urllib3.connectionpool:https://api.foursquare.com:443 "GET /v2/venues/49eeaf08f964a52078681fe3?oauth_token=<SNIP>&v=20180611 HTTP/1.1" 200 None
Out[56]: <Response [200]>
In [57]: dict(_57.headers)
Out[57]:
{'Accept-Ranges': 'bytes',
'Access-Control-Allow-Origin': '*',
'Connection': 'keep-alive',
'Content-Encoding': 'gzip',
'Content-Type': 'application/json; charset=utf-8',
'Date': 'Mon, 11 Jun 2018 14:35:01 GMT',
'Server': 'nginx',
'Strict-Transport-Security': 'max-age=31536000',
'Tracer-Time': '257',
'Transfer-Encoding': 'chunked',
'Vary': 'Accept-Encoding,User-Agent,Accept-Language',
'Via': '1.1 varnish',
'X-Cache': 'MISS',
'X-Cache-Hits': '0',
'X-Rate-Limit-Key': '77.49.114.206',
'X-RateLimit-Limit': '0',
'X-RateLimit-Path': '/v2/venues/X',
'X-RateLimit-Remaining': '0',
'X-Served-By': 'cache-hhn1530-HHN',
'X-ex': 'fastly_cdn'}
Finally, non-premium requests work with our application credentials without a problem:
In [59]: requests.get('https://api.foursquare.com/v2/venues/49eeaf08f964a52078681fe3/similar', params={'client_id': settings.FOURSQUARE_CLIENT_ID, 'client_secret': settings.FOURSQUARE_CLIENT_SECRET, 'v': '20180611'})
2018-06-11 14:50:33,378:DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.foursquare.com
2018-06-11 14:50:33,790:DEBUG:urllib3.connectionpool:https://api.foursquare.com:443 "GET /v2/venues/49eeaf08f964a52078681fe3/similar?client_secret=<SNIP>&client_id=<SNIP>&v=20180611 HTTP/1.1" 200 None
Out[59]: <Response [200]>
In [60]: dict(_59.headers)
Out[60]:
{'Accept-Ranges': 'bytes',
'Access-Control-Allow-Origin': '*',
'Connection': 'keep-alive',
'Content-Encoding': 'gzip',
'Content-Type': 'application/json; charset=utf-8',
'Date': 'Mon, 11 Jun 2018 14:50:33 GMT',
'Server': 'nginx',
'Strict-Transport-Security': 'max-age=31536000',
'Tracer-Time': '18',
'Transfer-Encoding': 'chunked',
'Vary': 'Accept-Encoding,User-Agent,Accept-Language',
'Via': '1.1 varnish',
'X-Cache': 'MISS',
'X-Cache-Hits': '0',
'X-Rate-Limit-Key': '77.49.114.206',
'X-RateLimit-Limit': '10000',
'X-RateLimit-Path': '/v2/venues/X/similar',
'X-RateLimit-Remaining': '9993',
'X-Served-By': 'cache-hhn1529-HHN',
'X-ex': 'fastly_cdn'}
Any idea what is the quota/rate limit problem here and how to fix it?

Related

Twitter API works on one IP but not the other

I am currently building a Twitter bot in Nodejs with twitter-api-v2 library. The below error is from the likes API that I use to like people's tweets.
When I first finished the app and deployed it to the server, it was working fine until it wasn't. It started to give me 429 Too Many Requests error despite that I have available rate limit left (As shown in the error below).
What is more interesting is that while it isn't working in my server, the app works fine on my localhost and it only throws 429 when the rate limit is used up. (I am NOT using docker)
The only difference I noticed about these two error responses is that on my server, it is reaching server tsa_p, but on my localhost it is reaching server tsa_b
What could this mean? Does Twitter API have hidden restriction on the amount of requests you can make per IP? Why can server tsa_b handle my request but tsa_p couldn't?
ApiResponseError: Request failed with code 429
at RequestHandlerHelper.createResponseError (/srv/twitterbots/auto_like_bot/node_modules/twitter-api-v2/dist/cjs/client-mixins/request-handler.helper.js:103:16)
at RequestHandlerHelper.onResponseEndHandler (/srv/twitterbots/auto_like_bot/node_modules/twitter-api-v2/dist/cjs/client-mixins/request-handler.helper.js:252:25)
at Gunzip.emit (node:events:513:28)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
error: true,
type: 'response',
code: 429,
headers: {
date: 'Sat, 21 Jan 2023 03:08:24 UTC',
perf: '7626143928',
server: 'tsa_p',
'set-cookie': [
'guest_id_marketing=v1%3A167427050431236487; Max-Age=63072000; Expires=Mon, 20 Jan 2025 03:08:24 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None',
'guest_id_ads=v1%3A167427050431236487; Max-Age=63072000; Expires=Mon, 20 Jan 2025 03:08:24 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None',
'personalization_id="v1_vOZZLJVrhS4Q78smd3/U9g=="; Max-Age=63072000; Expires=Mon, 20 Jan 2025 03:08:24 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None',
'guest_id=v1%3A167427050431236487; Max-Age=63072000; Expires=Mon, 20 Jan 2025 03:08:24 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None'
],
'api-version': '2.61',
'content-type': 'application/json; charset=utf-8',
'cache-control': 'no-cache, no-store, max-age=0',
'content-length': '94',
'x-access-level': 'read-write',
'x-frame-options': 'SAMEORIGIN',
'content-encoding': 'gzip',
'x-transaction-id': '32cdfb3dfd64d27a',
'x-xss-protection': '0',
'x-rate-limit-limit': '50',
'x-rate-limit-reset': '1674271132',
'content-disposition': 'attachment; filename=json.json',
'x-content-type-options': 'nosniff',
'x-rate-limit-remaining': '46',
'strict-transport-security': 'max-age=631138519',
'x-response-time': '51',
'x-connection-hash': '5dbb0f4de195912f76293e11543a8685a6b1c296b5067ace43de9f665bbba298',
connection: 'close'
},
rateLimit: { limit: 50, remaining: 46, reset: 1674271132 },
data: {
title: 'Too Many Requests',
detail: 'Too Many Requests',
type: 'about:blank',
status: 429
}
}

mongodb-runner does not work(Response code 403)

So, I wanted to setup my mongoDB + Parse Server on my Kali Linux server.
I followed the instructions on this Git-Repo: https://github.com/parse-community/parse-server
When typing npm install -g parse-server mongodb-runner
and mongodb-runner start I get the following log:
TPError: Response code 403 (Forbidden)
at EventEmitter.ee.on.res (/usr/local/lib/node_modules/mongodb-runner/node_modules/got/index.js:250:24)
at EventEmitter.emit (events.js:182:13)
at Immediate.setImmediate (/usr/local/lib/node_modules/mongodb-runner/node_modules/got/index.js:99:8)
at runCallback (timers.js:694:18)
at tryOnImmediate (timers.js:665:5)
at processImmediate (timers.js:647:5)
name: 'HTTPError',
host: 'fastdl.mongodb.org',
hostname: 'fastdl.mongodb.org',
method: 'GET',
path: '/linux/mongodb-linux-x86_64-4.2.8.tgz',
protocol: 'https:',
url:
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.2.8.tgz',
statusCode: 403,
statusMessage: 'Forbidden',
headers:
{ 'content-type': 'application/xml',
'transfer-encoding': 'chunked',
connection: 'close',
date: 'Mon, 15 Jun 2020 10:17:34 GMT',
server: 'AmazonS3',
'x-cache': 'Error from cloudfront',
via:
'1.1 6b4954a8411e7b2a232537f8000c5c9d.cloudfront.net (CloudFront)',
'x-amz-cf-pop': 'FRA50-C1',
'x-amz-cf-id': 'af_MHWQpIoBDL77-FBQHI5BED9OTX2E_kOGfHNg-LF9ujCGiCUGW2g==' } }
{ HTTPError: Response code 403 (Forbidden)
at EventEmitter.ee.on.res (/usr/local/lib/node_modules/mongodb-runner/node_modules/got/index.js:250:24)
at EventEmitter.emit (events.js:182:13)
at Immediate.setImmediate (/usr/local/lib/node_modules/mongodb-runner/node_modules/got/index.js:99:8)
at runCallback (timers.js:694:18)
at tryOnImmediate (timers.js:665:5)
at processImmediate (timers.js:647:5)
name: 'HTTPError',
host: 'fastdl.mongodb.org',
hostname: 'fastdl.mongodb.org',
method: 'GET',
path: '/linux/mongodb-linux-x86_64-4.2.8.tgz',
protocol: 'https:',
url:
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.2.8.tgz',
statusCode: 403,
statusMessage: 'Forbidden',
headers:
{ 'content-type': 'application/xml',
'transfer-encoding': 'chunked',
connection: 'close',
date: 'Mon, 15 Jun 2020 10:17:34 GMT',
server: 'AmazonS3',
'x-cache': 'Error from cloudfront',
via:
'1.1 6b4954a8411e7b2a232537f8000c5c9d.cloudfront.net (CloudFront)',
'x-amz-cf-pop': 'FRA50-C1',
'x-amz-cf-id': 'af_MHWQpIoBDL77-FBQHI5BED9OTX2E_kOGfHNg-LF9ujCGiCUGW2g==' } }
I dont know what to do. Did I install any wrong packages or something like that?

When i am removing my account from stripe in node it gives some err

I get the error:
You cannot delete the default external account for your default currency. Please make another external account the default using the default_for_currency param, and then delete this one.
err1 StripeInvalidRequestError: You cannot delete the default external account for your default currency. Please make another external account the default using the default_for_currency param, and then delete this one.
at Function.generate (/var/www/html/SageRider/node_modules/stripe/lib/Error.js:38:16)
at IncomingMessage. (/var/www/html/SageRider/node_modules/stripe/lib/StripeResource.js:175:33)
at Object.onceWrapper (events.js:299:28)
at IncomingMessage.emit (events.js:215:7)
at endReadableNT (_stream_readable.js:1199:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
type: 'StripeInvalidRequestError',
raw: {
message: 'You cannot delete the default external account for your default currency. Please make another external account the default using the default_for_currency param, and then delete this one.',
type: 'invalid_request_error',
headers: {
server: 'nginx',
date: 'Thu, 25 Jun 2020 19:28:55 GMT',
'content-type': 'application/json',
'content-length': '264',
connection: 'keep-alive',
'access-control-allow-credentials': 'true',
'access-control-allow-methods': 'GET, POST, HEAD, OPTIONS, DELETE',
'access-control-allow-origin': '*',
'access-control-expose-headers': 'Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required',
'access-control-max-age': '300',
'cache-control': 'no-cache, no-store',
'request-id': 'req_bXINneBUbmPyo2',
'stripe-account': 'acct_1GwmPSFNjTTd70ro',
'stripe-version': '2019-12-03',
'strict-transport-security': 'max-age=31556926; includeSubDomains; preload'
},
statusCode: 400,
requestId: 'req_bXINneBUbmPyo2'
},
rawType: 'invalid_request_error',
code: undefined,
param: undefined,
detail: undefined,
headers: {
server: 'nginx',
date: 'Thu, 25 Jun 2020 19:28:55 GMT',
'content-type': 'application/json',
The code I use is:
stripe.accounts.deleteExternalAccount(
cryptr.decrypt(data[0].accountId),
cryptr.decrypt(data[0].bankAccountId),
function(err, confirmation) {
if(err) {
console.log("err1",err)
callback(err, false)
}else {
console.log("confirmation",confirmation)
callback(false, true)
}
Today, you can not remove the last external account saved on a Custom account in the API. Stripe requires that an account always has a valid bank account for the currency once you've added this.
My guess is that this is the error you are getting right now though you didn't share the exact message. In that case, you need to change your code to stop removing the last external account or replace it by a new external account instead.

Github 304 responses seem to count against rate limit

I'm running into an issue with the github api counting requests that yeild a 304 response against the rate limit
GET /repos/******/***/contents/***?ref=master HTTP/1.1
Host: api.github.com
Connection: keep-alive
Cache-Control: max-age=0
Sec-Fetch-Dest: empty
If-None-Match: W/"b15846765021dc2483e5f3110b53a69f210ececa"
If-Modified-Since: Thu, 19 Mar 2020 01:33:51 GMT
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36
Accept: */*
Origin: *******
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: cors
Referer: ******
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
this request will return with a 304 and no body, but X-Ratelimit-Remaining decrements.
Conditional Github Requests
Note: Making a conditional request and receiving a 304 response does not count against your Rate Limit, so we encourage you to use it whenever possible.
I'm only setting the If-None-Match and If-Modified-Since headers, the rest are set by the browser (using fetch api)
Request
This can be replicated with just a browser by navigating to https://api.github.com/repos/angular/angular/contents/?ref=master and making sure disable cache is off in the developer console
Responses
On first call
If-None-Match and If-Modified-Since are not set
HTTP/1.1 200 OK
date: Wed, 01 Apr 2020 12:43:09 GMT
content-type: application/json; charset=utf-8
server: GitHub.com
status: 200 OK
cache-control: public, max-age=60, s-maxage=60
vary: Accept, Accept-Encoding, Accept, X-Requested-With
etag: W/"b15846765021dc2483e5f3110b53a69f210ececa"
last-modified: Thu, 19 Mar 2020 01:33:51 GMT
x-github-media-type: github.v3; format=json
access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
access-control-allow-origin: *
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'
content-encoding: gzip
X-Ratelimit-Limit: 60
X-Ratelimit-Remaining: 59
X-Ratelimit-Reset: 1585748589
Accept-Ranges: bytes
Content-Length: 1696
X-GitHub-Request-Id: B298:74D9:10D7B8:177665:5E848C5D
followed by the requested data
Subsequent Calls:
If-None-Match and If-Modified-Since are set to etag and last-modified header from previous request
HTTP/1.1 304 Not Modified
date: Wed, 01 Apr 2020 12:44:51 GMT
content-type: application/json; charset=utf-8
server: GitHub.com
status: 200 OK
cache-control: public, max-age=60, s-maxage=60
vary: Accept, Accept-Encoding, Accept, X-Requested-With
etag: W/"b15846765021dc2483e5f3110b53a69f210ececa"
last-modified: Thu, 19 Mar 2020 01:33:51 GMT
x-github-media-type: github.v3; format=json
access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
access-control-allow-origin: *
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'
content-encoding: gzip
X-Ratelimit-Limit: 60
X-Ratelimit-Remaining: 58
X-Ratelimit-Reset: 1585748589
X-GitHub-Request-Id: FC10:2036:26E528:346432:5E848CC3
no data is returned.
According to the documentation X-Ratelimit-Remaining should have stayed at 59
Is there something wrong with my request or is there a bug with the ratelimit on githubs end?
got the same problem. and resolved it. i've added to headers 'Authorization' key with string value. i'm using python and requests for humans. so in my console looks this like that:
>>> response = requests.get('http://api.github.com/repos/zappycode/zappycode-django/commits', headers={'Authorization': 'JustaString', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0', 'If-Modified-Since': 'Sat, 18 Jul 2020 00:15:14 GMT'})
>>> response.headers
{'Date': 'Tue, 21 Jul 2020 09:06:05 GMT', 'Server': 'GitHub.com', 'Status': '304 Not Modified', 'X-RateLimit-Limit': '60', 'X-RateLimit-Remaining': '59', 'X-RateLimit-Reset': '1595323695', 'Cache-Control': 'public, max-age=60, s-maxage=60', 'Vary': 'Accept, Accept-Encoding, Accept, X-Requested-With, Accept-Encoding', 'ETag': '"03e2ffed23748e4e7fee925076e63b47"', 'Last-Modified': 'Sat, 18 Jul 2020 00:15:14 GMT', 'Access-Control-Expose-Headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset', 'Access-Control-Allow-Origin': '*', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains; preload', 'X-Frame-Options': 'deny', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Referrer-Policy': 'origin-when-cross-origin, strict-origin-when-cross-origin', 'Content-Security-Policy': "default-src 'none'", 'X-GitHub-Request-Id': 'B6AC:EC41:82A5D:B3030:5F16AFFD'}
>>> response_2 = requests.get('http://api.github.com/repos/zappycode/zappycode-django/commits', headers={'Authorization': 'JustaString', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0', 'If-Modified-Since': 'Sat, 18 Jul 2020 00:15:14 GMT'})
>>> response_2.headers
{'Date': 'Tue, 21 Jul 2020 09:06:44 GMT', 'Server': 'GitHub.com', 'Status': '304 Not Modified', 'X-RateLimit-Limit': '60', 'X-RateLimit-Remaining': '59', 'X-RateLimit-Reset': '1595323695', 'Cache-Control': 'public, max-age=60, s-maxage=60', 'Vary': 'Accept, Accept-Encoding, Accept, X-Requested-With, Accept-Encoding', 'ETag': '"03e2ffed23748e4e7fee925076e63b47"', 'Last-Modified': 'Sat, 18 Jul 2020 00:15:14 GMT', 'Access-Control-Expose-Headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset', 'Access-Control-Allow-Origin': '*', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains; preload', 'X-Frame-Options': 'deny', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Referrer-Policy': 'origin-when-cross-origin, strict-origin-when-cross-origin', 'Content-Security-Policy': "default-src 'none'", 'X-GitHub-Request-Id': 'A962:EC4D:11CCB9AF:15D06EA5:5F16B023'}
>>> response_3 = requests.get('http://api.github.com/repos/zappycode/zappycode-django/commits', headers={'Authorization': 'JustaString', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0', 'If-Modified-Since': 'Sat, 18 Jul 2020 00:15:14 GMT'})
>>> response_3.headers
{'Date': 'Tue, 21 Jul 2020 09:07:39 GMT', 'Server': 'GitHub.com', 'Status': '304 Not Modified', 'X-RateLimit-Limit': '60', 'X-RateLimit-Remaining': '59', 'X-RateLimit-Reset': '1595323695', 'Cache-Control': 'public, max-age=60, s-maxage=60', 'Vary': 'Accept, Accept-Encoding, Accept, X-Requested-With, Accept-Encoding', 'ETag': '"03e2ffed23748e4e7fee925076e63b47"', 'Last-Modified': 'Sat, 18 Jul 2020 00:15:14 GMT', 'Access-Control-Expose-Headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset', 'Access-Control-Allow-Origin': '*', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains; preload', 'X-Frame-Options': 'deny', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Referrer-Policy': 'origin-when-cross-origin, strict-origin-when-cross-origin', 'Content-Security-Policy': "default-src 'none'", 'X-GitHub-Request-Id': 'A968:69B0:11A84908:159BBA46:5F16B05B'}
hope it's gonna work for u :)
According to the documentation X-Ratelimit-Remaining should have stayed at 59
This 59 here suggests that you're performing unauthenticated requests, which might be key here. I wonder if this is related to the rate limits for unauthenticated requests not being measured in the same way as authenticated requests, and this situation may not be considered a "conditional" request.
This case is not documented explicitly, but GitHub highly recommends using authenticated requests as these rate limits are tracked per-account, not per-IP address.

how to read data from apiResponse in Nodejs typescript?

I want to read data from a googleapis call. I am using async-await. But I am not sure how to read the data that I am getting back.
async function makeCall(params:String){
const apiResponse = await goopleapi.particular.get(params);
console.log(`not really sure how to read -- ${apiResponse}`;
// problem is the log prints [object Object].
}
How do I get the log from printing [object Object] to the actual content of the response? Ultimately I want to read the json that comes back -- how do I do that? Thanks.
In case it's important. I am using Firebase as a back-end with Typescript
udpate 1
The api in question is for billing. As in https://www.googleapis.com/auth/androidpublisher. I am calling .purchases.products.get. And when I try to parse the response with JSON.parse(apiResponse), I get the error:
SyntaxError: Unexpected token o in JSON at position 1
at JSON.parse (<anonymous>)
at getItem (/srv/lib/index.js:31:69)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:145:8)
documentation: https://developers.google.com/android-publisher/api-ref/purchases/products/get
update 2
Here is the apiResponse that I need to parse into json. I tried using JSON.parse(apiResponse) but got an error:
{ config:
{ url: 'https://www.googleapis.com/androidpublisher/v2/applications/mypath',
method: 'GET',
paramsSerializer: [Function],
headers:
{ 'Accept-Encoding': 'gzip',
'User-Agent': 'google-api-nodejs-client/2.0.0 (gzip)',
Authorization: 'Bearer somecode',
Accept: 'application/json' },
params: {},
validateStatus: [Function],
retry: true,
responseType: 'json' },
data:
{ kind: 'androidpublisher#productPurchase',
purchaseTimeMillis: '111222333',
purchaseState: 0,
consumptionState: 1,
developerPayload: '',
orderId: 'some string',
purchaseType: 0 },
headers:
{ 'alt-svc': 'quic=":111"; ma=33445566; v="a string"',
'cache-control': 'private, max-age=0, must-revalidate, no-transform',
connection: 'close',
'content-encoding': 'gzip',
'content-type': 'application/json; charset=UTF-8',
date: 'Fri, 14 Jun 2019 12:40:12 GMT',
etag: '"some string"',
expires: 'Fri, 14 Jun 2019 12:40:12 GMT',
server: 'GSE',
'transfer-encoding': 'chunked',
vary: 'Origin, X-Origin',
'x-content-type-options': 'nosniff',
'x-frame-options': 'SAMEORIGIN',
'x-xss-protection': '1; mode=block' },
status: 200,
statusText: 'OK' }
The error is still the same as in "update 1"
Template strings will call toString on the parts. You need to do
console.log('You need to pass it as a parameter', apiResponse)
If you want to print the actual object to the console.
The object has already been parsed. The error is from passing json to JSON.parse() which expects a string.
[object Object] is returned from the objects toString() method in a template literal, to avoid this:
console.log('Some string',apiResponse);
if theres still a problem try console.log(JSON.stringify(apiResponse))

Resources