mongodb-runner does not work(Response code 403) - node.js

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?

Related

PayPal 401 Client Authentication Failed in Sandbox environment with node js sdk

I've followed this guide https://developer.paypal.com/docs/checkout/reference/server-integration/setup-sdk/ and this example https://github.com/paypal/Checkout-Nodejs-SDK/
Here is my code:
import paypalCheckout from '#paypal/checkout-server-sdk';
const environment = new paypalCheckout.core.SandboxEnvironment(
'ACTUAL_CLIENT_ID_FROM_PAYPAL_DASHBOARD',
'ACTUAL_CLIENT_SECRET_FROM_PAYPAL_DASHBOARD'
);
const client = new paypalCheckout.core.PayPalHttpClient(environment);
const request = new paypalCheckout.orders.OrdersCreateRequest();
request.requestBody({
intent: 'CAPTURE',
purchase_units: [
{
amount: {
currency_code: 'USD',
value: `100.00`
}
}
],
});
client.execute(request)
.then((response) => {
console.log(`${JSON.stringify(response)}`);
console.log(`${JSON.stringify(response?.result)}`);
})
.catch((executeError) => {
console.log(`${JSON.stringify(executeError)}`);
});
I get:
{
error: HttpError: {"error":"invalid_client","error_description":"Client Authentication failed"}
at IncomingMessage.<anonymous> (.../node_modules/#paypal/paypalhttp/lib/paypalhttp/http_client.js:136:22)
at IncomingMessage.emit (events.js:388:22)
at endReadableNT (internal/streams/readable.js:1336:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
statusCode: 401,
headers: {
'content-type': 'application/json',
'content-length': '77',
connection: 'close',
date: 'Tue, 29 Jun 2021 01:22:38 GMT',
'cache-control': 'max-age=0, no-cache, no-store, must-revalidate',
'paypal-debug-id': 'c2b.......c7a',
'x-paypal-token-service': 'IAAS',
'strict-transport-security': 'max-age=31536000; includeSubDomains'
},
_originalError: {
text: '{"error":"invalid_client","error_description":"Client Authentication failed"}',
statusCode: 401,
headers: [Object]
}
},
message: '{"error":"invalid_client","error_description":"Client Authentication failed"}'
}
I've searched Google and Stack Overflow but I only find similar issues about switching from sandbox to live.
My code isn't working in sandbox environment.

ResponseError: Forbidden

When I am trying to run node src/emails/account.js, this issues is showing me in my terminal, besides this i had also verified single sender request:
ResponseError: Forbidden
at Request._callback (node_modules/#sendgrid/client/src/classes/cl​‌​
ient.js:124:25)
at Request.self.callback (node_modules/request/request.js:185:22)
at Request.emit (events.js:321:20)
at Request.<anonymous> (node_modules/request/request.js:1154:10)
at Request.emit (events.js:321:20)
at IncomingMessage.<anonymous> (node_modules/request/request.js:10​‌​
76:12)
at Object.onceWrapper (events.js:427:28)
at IncomingMessage.emit (events.js:333:22)
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:2​‌​
1) {
code: 403,
message: 'Forbidden',
response: {
headers: {
server: 'nginx',
date: 'Sun, 12 Jul 2020 12:35:21 GMT',
'content-type': 'application/json',
'content-length': '281',
connection: 'close',
'access-control-allow-origin': 'https://sendgrid.api-docs.io',
'access-control-allow-methods': 'POST',
'access-control-allow-headers': 'Authorization, Content-Type, On​‌​
-behalf-of, x-sg-elas-acl',
'access-control-max-age': '600',
'x-no-cors-reason': 'https://sendgrid.com/docs/Classroom/Basics/​‌​
API/cors.html'
},
body: { errors: [Array] }
}
}
I had this same error and I found out that my verified email address in my node js app was wrong. Error 403 essentially means forbidden, which means that you don't have verified access. Try checking your verified email or API key. This will most likely solve any issues

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.

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))

How to correctly create a stripe source from a stripe token

I am attempting to create a stripe source server-side from a stripe token received client-side. When using console.log(), the token is the correct one retrieved from the client-side, but the error message I am receiving refers to a token that I did not even pass into the Stripe source promise.
Client side js
stripe.createToken(card).then(function(result) {
if (result.error) {
// Inform the user if there was an error.
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
document.getElementById('token').setAttribute('value',result.token.id);
document.getElementById('type').setAttribute('value',result.token.type);
myForm.submit();
}
});
and on my server I have the following...
router.post("/purchase",middleware.isLoggedIn, function(req,res){
let tokenId = req.body.token;
let type = req.body.type;
console.log(tokenId);
stripe.sources.create({
token: tokenId,
type: req.body.type
}).then((source) => {
console.log(source);
}).catch((e) =>{
console.log(tokenId);
console.log(e);
});
});
});
I get the following result from the conole.log(tokenId) statement
tok_1CdT3H2eZvKYlo2CNGY0W0JJ
but my error message from console.log(e) refers to a token beginning with 'card' that was not passed into the promise, which is the source of my confusion.
{ Error: Invalid token id: card_1CdT3H2eZvKYlo2Cv1PzIBCv
at Error._Error (/home/ec2-user/environment/node_modules/stripe/lib/Error.js:12:17)
at Error.Constructor (/home/ec2-user/environment/node_modules/stripe/lib/utils.js:124:13)
at Error.Constructor (/home/ec2-user/environment/node_modules/stripe/lib/utils.js:124:13)
at Function.StripeError.generate (/home/ec2-user/environment/node_modules/stripe/lib/Error.js:57:12)
at IncomingMessage.<anonymous> (/home/ec2-user/environment/node_modules/stripe/lib/StripeResource.js:170:39)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
type: 'StripeInvalidRequestError',
stack: 'Error: Invalid token id: card_1CdT3H2eZvKYlo2Cv1PzIBCv\n at Error._Error (/home/ec2-user/environment/node_modules/stripe/lib/Error.js:12:17)\n at Error.Constructor (/home/ec2-user/environment/node_modules/stripe/lib/utils.js:124:13)\n at Error.Constructor (/home/ec2-user/environment/node_modules/stripe/lib/utils.js:124:13)\n at Function.StripeError.generate (/home/ec2-user/environment/node_modules/stripe/lib/Error.js:57:12)\n at IncomingMessage.<anonymous> (/home/ec2-user/environment/node_modules/stripe/lib/StripeResource.js:170:39)\n at emitNone (events.js:91:20)\n t IncomingMessage.emit (events.js:185:7)\n at endReadableNT (_stream_readable.js:974:12)\n at _combinedTickCallback (internal/process/next_tick.js:80:11)\n at process._tickDomainCallback (internal/process/next_tick.js:128:9)',
rawType: 'invalid_request_error',
code: 'invalid_token_id',
param: undefined,
message: 'Invalid token id: card_1CdT3H2eZvKYlo2Cv1PzIBCv',
detail: undefined,
raw:
{ code: 'invalid_token_id',
message: 'Invalid token id: card_1CdT3H2eZvKYlo2Cv1PzIBCv',
type: 'invalid_request_error',
headers:
{ server: 'nginx',
date: 'Sat, 16 Jun 2018 01:18:04 GMT',
'content-type': 'application/json',
'content-length': '155',
connection: 'close',
'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_EfxhCBwQpauiVP',
'stripe-version': '2017-08-15' },
statusCode: 400,
requestId: 'req_EfxhCBwQpauiVP' },
headers:
{ server: 'nginx',
date: 'Sat, 16 Jun 2018 01:18:04 GMT',
'content-type': 'application/json',
'content-length': '155',
connection: 'close',
'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_EfxhCBwQpauiVP',
'stripe-version': '2017-08-15' },
requestId: 'req_EfxhCBwQpauiVP',
statusCode: 400 }
Technically you can but it's likely a lot easier to just create a Source client-side directly instead of creating a token. Elements can create a Source, so does Checkout withe source callback.
If you really want to do this server-side, just pass the token in the token parameter when you create the Card Source.

Resources