Mandrill Authentication error for meteorjs local application - email

I am trying to integrate Mandrill to send and receive emails in my application. I am doing the following from http://localhost:3000 -
Run following to add mandrill to meteor project -
meteor add wylio:mandrill
put the following in server startup -
Meteor.startup(function() {
return Meteor.Mandrill.config({
username: "mandrill-user-id#gmail.com",
key: "Valid API Key generated in Mandrill",
password: "Valid API Key generated in Mandrill",
});
});
Then call the following to send the email -
Meteor.Mandrill.send(
{ host: "smtp.mandrillapp.com"
, port: 587
, to: to//"customer#anydomain.com"
, from: from //"you#yourdomain.com"
, subject: "Mandrill knows Javascript!"
, body: "Hello from NodeJS!"
, authentication: "LOGIN"
, username: "username#gmail.com"//username
, password: "API Key from mandrill page"//password
}, function(err, result){
if(err){
console.log(err);
}
}
);
When I try sending the email, I get the following error -
Exception while invoking method 'sendQollMail' AuthError: Invalid login - 535 Authentication failed: Bad username / password
at Object.Future.wait (/Users/priyanka/.meteor/packages/meteor-tool/.1.0.40.1qwqep8++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:326:15)
at smtpSend (packages/email/email.js:91:1)
at Object.Email.send (packages/email/email.js:168:1)
at Object.Meteor.Mandrill.send (packages/wylio:mandrill/mandrill.js:12:1)
at Object.QollMailer.sendQollEmail (app/server/lib/QollMailer.js:58:21)
at [object Object].Meteor.methods.sendQollMail (app/server/lib/QollMailer.js:87:27)
at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1599:1)
at packages/ddp/livedata_server.js:648:1
at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
at packages/ddp/livedata_server.js:647:1
- - - - -
at SMTPClient._actionAUTHComplete (/Users/priyanka/.meteor/packages/email/.1.0.5.s8780m++os+web.browser+web.cordova/npm/node_modules/simplesmtp/lib/client.js:826:23)
at SMTPClient._onData (/Users/priyanka/.meteor/packages/email/.1.0.5.s8780m++os+web.browser+web.cordova/npm/node_modules/simplesmtp/lib/client.js:329:29)
at CleartextStream.emit (events.js:95:17)
at CleartextStream.<anonymous> (_stream_readable.js:764:14)
at CleartextStream.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:426:10)
at _stream_readable.js:419:7
at process._tickCallback (node.js:419:13)
Can you tell me what am I doing wrong here?

I was doing everything correct. Except that - sometimes back I had tried integrating with mailgun (or some other service). That required setting up following env variable -
process.env.MAIL_URL = 'smtp://username:password#host:port';
This was overriding the username/password in mandrill. Taking it out resolved the issue.

Related

Error Parsing HTTP Response Using Apama HTTP Client plugin

I am trying to do an HTTP call to a REST API using Apama HTTP Client plugin. I am able to send a request to the REST Resource, but while parsing the response, I am getting the below error.
WARN [20176] - Failed to parse the event "`{contentType:application/json,sag.type:apamax.httpserversample.HTTPResponse,http:{headers:{contentLength:50,content-type:application/json,content-length:50},statusCode:200,method:POST,path:/rest/POC_422837/WS/provider/apamaTestConn,cookies:{},statusReason:OK}}{body:{status:Hello Apama. How are you doing?}}"
from httpClient due to the error: Unable to parse event apamax.httpserversample.HTTPResponse:
Unable to parse string from the map '{status:Hello Apama. How are you doing?}':
Invalid datatype, could not cast to string`
The YAML Config file looks as below,
connectivityPlugins:
HTTPClientGenericTransport:
libraryName: connectivity-http-client
class: HTTPClient
startChains:
httpClient:
- apama.eventMap
- mapperCodec:
apamax.httpserversample.HTTPRequest:
towardsTransport:
mapFrom:
- metadata.http.path: payload.path
- metadata.requestId: payload.id
- metadata.http.method: payload.method
- payload: payload.data
defaultValue:
- metadata.contentType: application/json
- metadata.sag.type: HelloWorld
apamax.httpserversample.HTTPResponse:
towardsHost:
mapFrom:
- payload.body: payload
- payload.id: metadata.requestId
apamax.httpserversample.HTTPError:
towardsHost:
mapFrom:
- payload.id: metadata.requestId
- payload.code: metadata.http.statusCode
- payload.message: metadata.http.statusReason
- classifierCodec:
rules:
- apamax.httpserversample.HTTPResponse:
- metadata.http.statusCode: 200
- apamax.httpserversample.HTTPError:
- metadata.http.statusCode:
- jsonCodec:
filterOnContentType: true
- stringCodec
- HTTPClientGenericTransport:
host: ${CORRELATOR_HOST}
port: ${CORRELATOR_PORT}
Please help.
I believe the problem is that you map in the config
apamax.httpserversample.HTTPResponse:
towardsHost:
mapFrom:
- payload.body: payload
- payload.id: metadata.requestId
the payload of the response to HTTPResponse.body.
However, as you can see from the warning, the payload is actually a map, so you need to do
- payload.body: payload.status

Sails application fails to connect localhost mongo db

My sails application not able to connect to locally running mongo db instance
local.js is like below
module.exports.connections = {
sailsMongoDBServer: {
adapter: 'sails-mongo',
host: '127.0.0.1',
port: 27017,
database: 'dp-manager-db'
}
}
Error :
2019-03-06T12:32:01.081Z - error:
{ message:
'The hook `orm` is taking too long to load.\nMake sure it is triggering its `initialize()` callback, or else set `sails.config.orm._hookTimeout to a higher value (currently 20000)',
stack:
'Error: The hook `orm` is taking too long to load.\nMake sure it is triggering its `initialize()` callback, or else set `sails.config.orm._hookTimeout to a higher value (currently 20000)\n at Timeout.tooLong [as _onTimeout] (E:\\workspace_DpForm\\Eclipse\\dpm-app\\node_modules\\sails\\lib\\app\\private\\loadHooks.js:85:21)\n at ontimeout (timers.js:436:11)\n at tryOnTimeout (timers.js:300:5)\n at listOnTimeout (timers.js:263:5)\n at Timer.processTimers (timers.js:223:10)',
code: 'E_HOOK_TIMEOUT' }
2019-03-06T12:32:03.521Z - error: A hook (`orm`) failed to load!
E:\workspace_DpForm\Eclipse\dpm-app\node_modules\mongodb\lib\mongo_client.js:224
throw err

can we connect to public api endpoint instead of local host using dredd tool?

I tried to use a public end point(eg:api.openweathermap.org/data/2.5/weather?lat=35&lon=139) instead of the local host while configuring dredd and ran the command to run the tool.But I am not able to connect to the end point through dredd. It is throwing Error:getaddrINFO EAI_AGAIN .
But when I tried to connect to the endpoint using post man .I am able to connect successfully
There is no difference in calling a local or remote endpoint.
Some remote endpoints have some sort of authorization requirements.
This an example of Dredd calling external endpoint:
dredd.yml configuration file fragment
...
blueprint: doc/api.md
# endpoint: 'http://api-srv:5000'
endpoint: https://private-da275-notes69.apiary-mock.com
As you see, the only change is the endpoint on Dredd configuration file (created using Dredd init).
But, as I mention, sometimes you'll need to provide authorization through the header or query string parameter.
Dreed has hooks that allow you to change things before each transaction, for instance:
You'd like to add the apikey parameter in each URL before executing the request. This code can handle that.
hook.js
// Writing Dredd Hooks In Node.js
// Ref: http://dredd.org/en/latest/hooks-nodejs.html
var hooks = require('hooks');
hooks.beforeEach(function(transaction) {
hooks.log('before each');
// add query parameter to each transaction here
let paramToAdd = 'api-key=23456';
if (transaction.fullPath.indexOf('?') > -1)
transaction.fullPath += '&' + paramToAdd;
else
transaction.fullPath += '?' + paramToAdd;
hooks.log('before each fullpath: ' + transaction.fullPath);
});
Code at Github gist
Save this hook file anywhere in your project an than run Dredd passing the hook file.
dredd --hookfiles=./hoock.js
That's it, after execution the log will show the actual URL used in the request.
info: Configuration './dredd.yml' found, ignoring other arguments.
2018-06-25T16:57:13.243Z - info: Beginning Dredd testing...
2018-06-25T16:57:13.249Z - info: Found Hookfiles: 0=/api/scripts/dredd-hoock.js
2018-06-25T16:57:13.263Z - hook: before each
2018-06-25T16:57:13.264Z - hook: before each fullpath: /notes?api-key=23456
"/notes?api-key=23456"
2018-06-25T16:57:16.095Z - pass: GET (200) /notes duration: 2829ms
2018-06-25T16:57:16.096Z - hook: before each
2018-06-25T16:57:16.096Z - hook: before each fullpath: /notes?api-key=23456
"/notes?api-key=23456"
2018-06-25T16:57:16.788Z - pass: POST (201) /notes duration: 691ms
2018-06-25T16:57:16.788Z - hook: before each
2018-06-25T16:57:16.789Z - hook: before each fullpath: /notes/abcd1234?api-key=23456
"/notes/abcd1234?api-key=23456"
2018-06-25T16:57:17.113Z - pass: GET (200) /notes/abcd1234 duration: 323ms
2018-06-25T16:57:17.114Z - hook: before each
2018-06-25T16:57:17.114Z - hook: before each fullpath: /notes/abcd1234?api-key=23456
"/notes/abcd1234?api-key=23456"
2018-06-25T16:57:17.353Z - pass: DELETE (204) /notes/abcd1234 duration: 238ms
2018-06-25T16:57:17.354Z - hook: before each
2018-06-25T16:57:17.354Z - hook: before each fullpath: /notes/abcd1234?api-key=23456
"/notes/abcd1234?api-key=23456"
2018-06-25T16:57:17.614Z - pass: PUT (200) /notes/abcd1234 duration: 259ms
2018-06-25T16:57:17.615Z - complete: 5 passing, 0 failing, 0 errors, 0 skipped, 5 total
2018-06-25T16:57:17.616Z - complete: Tests took 4372ms

How to connect to mongodb with authorization in meanjs?

I'm new to meanjs.
My problem is: my local mongodb has username/password, and I can't run meanjs demo successfully.
I git clone https://github.com/Azure-Samples/meanjs.git
And try to run it(npm run on Windows 10), but got this error:
Could not connect to MongoDB!
{ MongoError: Authentication failed.
at Function.MongoError.create (D:\Cordova\AzureMeanDemo\meanjs\node_modules\mongoose\node_modules\mongodb-core\lib\error.js:31:11)
then I set username/password in meanjs\config\env\development.js like:
db: {
uri: process.env.MONGOHQ_URL || process.env.MONGODB_URI || 'mongodb://' + (process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost') + '/mean-dev',
options: {
user: 'superAdmin', //here
pass: '*****' //here
},
// Enable mongoose debug mode
debug: process.env.MONGODB_DEBUG || false
},
...
but I still got the same error.
I've searched on google for a whole day, but got nothing about this.
Could anyone help me on this problem?
-------------- Solved -------------------
I changed uri: 'mongodb://username:passwd#localhost/mean-dev?authSource=adm‌​in'. It worked for me.
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/projectName,{user:'',pass:''});

symfony2 propel-bundle + postgres: syntax error near "."

this is for my login form which uses propel as user provider, I get this error which I can understand from, that identifiers are not quoted:
and error:
Unable to execute SELECT statement [SELECT user.id, user.username, user.password, user.email, user.type, user.first_name, user.last_name, user.national_code, user.personal_code, user.role, user.card, user.university_id, user.salt, user.active, user.created_at, user.updated_at FROM user WHERE user.username=:p1 LIMIT 1] [wrapped: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "." LINE 1: SELECT user.id, user.username, user.password, user.email, us... ^]
my propel configuration:
propel:
path: "%kernel.root_dir%/../vendor/propel"
phing_path: "%kernel.root_dir%/../vendor/phing"
logging: %kernel.debug%
dbal:
default_connection: default
connections:
default:
driver: %database_driver%
user: %database_user%
password: %database_password%
dsn: %database_driver%:host=%database_host%;dbname=%database_name%
options:
ATTR_PERSISTENT: false
attributes:
ATTR_EMULATE_PREPARES: true
settings:
charset: { value: UTF8 }
build_properties:
propel.database: %database_driver%
propel.database.url: ${propel.dsn}
propel.database.buildUrl: ${propel.database.url}
propel.database.createUrl: ${propel.database.buildUrl}
propel.database.user: %database_user%
propel.database.password: %database_password%
propel.platform.class: platform.${propel.database}Platform
propel.disableIdentifierQuoting: false
and also my provider config:
providers:
main:
propel:
class: National\PublicationBundle\Model\User
property: username
is something wrong with my config? I also found this on github and changed my code accordingly but it did change nothing, what I did:
\$sql = sprintf(
'$query',
implode(', ', array_map(function(\$e) { return '\"'.\$e.'\"' ; }, \$modifiedColumns)),
implode(', ', array_keys(\$modifiedColumns))
);
one more thing: when I generate sql wih php app/console propel:build:sql, sql codes are quoted correctly.
answer: user is a reserved word! so just changed it to users and solved! :\