WSO2 Identity Server OTP Email Configuration for SendGrid - email

I am getting crazy in setting email configuration for sendgrid.
I have followed steps for configuring Email OTP.
When I try the email is not being sent & in the logs I find the following exception:
[2019-01-23 13:15:42,756] ERROR {org.wso2.carbon.event.output.adapter.email.EmailEventAdapter} - Event dropped at Output Adapter 'EmailPublisher' for tenant id '-1234', Error in message format, null
javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:306)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
at org.wso2.carbon.event.output.adapter.email.EmailEventAdapter$EmailSender.run(EmailEventAdapter.java:306)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Entire documentation is about how to
Configure Gmail as the email OTP provider. I have done configuration based on the understanding I got from basic doc.
Please find configurations under the section in the /repository/conf/identity/application-authentication.xml configurations that I tried:
<AuthenticatorConfig name="EmailOTP" enabled="true">
<Parameter name="GmailClientId">gmailClientIdValue</Parameter>
<Parameter name="GmailClientSecret">gmailClientSecretValue</Parameter>
<Parameter name="SendgridAPIKey">S********1sLhYrS4_h7J1ehoBWA</Parameter>
<Parameter name="GmailRefreshToken">gmailRefreshTokenValue</Parameter>
<Parameter name="GmailEmailEndpoint">https://www.googleapis.com/gmail/v1/users/[userId]/messages/send</Parameter>
<Parameter name="SendgridEmailEndpoint">https://api.sendgrid.com/api/mail.send.json</Parameter>
<Parameter name="accessTokenRequiredAPIs">Gmail</Parameter>
<Parameter name="apiKeyHeaderRequiredAPIs">Sendgrid</Parameter>
<Parameter name="SendgridFormData">SendgridFormData</Parameter>
<Parameter name="SendgridURLParams">sc</Parameter>
<Parameter name="GmailAuthTokenType">Bearer</Parameter>
<Parameter name="GmailTokenEndpoint">https://www.googleapis.com/oauth2/v3/token</Parameter>
<Parameter name="SendgridAuthTokenType">Bearer</Parameter>
<Parameter name="redirectToMultiOptionPageOnFailure">false</Parameter>
</AuthenticatorConfig>
I think it's not documented well for sendgrid or I am not able to find it. Could anyone provide some reference or solution for the same?
Thanks in advance.

This error will be thrown when Gmail blocks an external party to sign in to the account. Turing on 'Less secure app access' at https://myaccount.google.com/security will solve this issue.

Related

How to set SMTP Office365 mail configuration in WSO2 Product

we are trying to set SMTP Mail configuration in WSO2 Product. Following steps for set SMTP Mail Configuration in WSO2BPMN Product.
Change SMTP Configuration in /conf/activiti.xml
<property name="mailServerHost" value="smtp.office365.com"/>
<property name="mailServerPort" value="587"/>
<property name="mailServerDefaultFrom" value="XXX#YYY.COM"/>
<property name="mailServerUseTLS" value="true"/>
<property name="mailServerUsername" value="XXX#YYY.COM"/>
<property name="mailServerPassword" value="XXX"/>
Restart Wso2BPMN product to apply changes in wso2bpmn.
But, we are facing the issue in send mail from Office365 through wso2bpmn product. Here, I have addressed the issue below,
Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.office365.com:587
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1398)
at org.apache.commons.mail.Email.send(Email.java:1423)
at org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior.execute(MailActivityBehavior.java:102)
... 192 more
Caused by: com.sun.mail.smtp.SMTPSendFailedException: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:780E0000, 17.43559:0000000094000000000000000000000000000000, 20.52176:140F9185000010100A00D231, 20.50032:140F9185701710100A00E231, 0.35180:62350000, 255.23226:0A00C931, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A000000, 16.55847:B2000000, 17.43559:0000000068010000000000000200000000000000, 20.52176:140F9185000010107B350000, 20.50032:140F91857017101080350000, 0.35180:0A00D330, 255.23226:85350000, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:8F350000, 4.21921:DC040000, 255.27962:FA000000, 255.1494:0A007530, 0.37692:04000100, 0.37948:04000100, 5.33852:00000000534D545000040480, 4.56248:DC040000, 7.40748:010000000000010B05000780, 7.57132:000000000000000000000000, 1.63016:32000000, 4.39640:DC040000, 8.45434:DD08C5FEDCC4AE4D81EB3D16E07C62BF00000000, 5.10786:0000000031352E32302E313432352E3030303A414D30505230374D42353436303A65353332653963312D613162352D343633372D383933632D35393263323535396364343300000000000000, 255.1750:2A310000, 255.31418:0A003F32, 0.22753:2F310000, 255.21817:DC040000, 4.60547:DC040000, 0.21966:0A009530, 4.30158:DC040000 [Hostname=AM0PR07MB5460.eurprd07.prod.outlook.com]
Please Provide me with any suggestion/idea for this.
Thanks,
Vivek KT.
the same thing happened to me. In my case, the problem is that I have never entered with that email account and it has not been configured. once configured it has worked well for me.
first connect to outlook.com and set up the account and then try wso2.
And i put all that email information in conf/axis2/axis2.xml

Unable to retrieve archived messages from new session

I am using EjabberD and have enabled MAM using
mod_mam:
default: always
I am able to retrieve only the messages I have sent using the client on the current session. If I logout and login again on the client, all the archived messages are deleted from the DB. (acertained by comparing Mnesia dumps before and after the second login).
I am using Strophe js based client.
The IQ Packet sent for getting the archived messages
<iq type="set" to="user1#x.x.x.x" xmlns="jabber:client" id="c0104a00-253e-4727-9157-a4ea24d9bc86:sendIQ">
<query xmlns="urn:xmpp:mam:2">
<x xmlns="jabber:x:data" type="submit">
<field var="FORM_TYPE" type="hidden">
<value>urn:xmpp:mam:2</value>
</field>
<field var="with">
<value>user1#x.x.x.x</value>
</field>
</x>
<set xmlns="http://jabber.org/protocol/rsm" />
</query>
</iq>
On strophe i logout from the server using
connection.disconnect();
connection.reset();
EDIT : Authentication mechanism is LDAP and ANON.
host_config:
"x.x.x.x":
auth_method:
- anonymous
- ldap
allow_multiple_connections: false
ldap_servers:
- "x.x.x.x"
ldap_encrypt: none
ldap_port: 389
ldap_base: "cn=Users,dc=x,dc=x,dc=x"
ldap_rootdn: "cn=Administrator,cn=Users,dc=x,dc=x,dc=x"
ldap_password: "xxx"
ldap_uids:
- "sAMAccountName": "%u"
I want the messages to be archived forever. So that the clients can retrieve the history without storing anything locally. What am I missing?
Are those accounts anonymous? If so, they are deleted when they logout, and all their related information is also deleted, like roster and mam messages.

Proxy service run through scheduled task in wso2 esb is giving error "Unexpected error sending message back"

We have created a proxy service in wso2 esb using esb poject in eclipse. This proxy service is invoking 2 web services, first one query data from legacy system and the other one creates sale order in oracle fusion.
This proxy service when run from soap ui executes successfully and creates sale order with no error. While when when run from scheduled task, it runs and creates order but gives error "Unexpected error sending message back {org.apache.synapse.core.axis2.Axis2Sender}" in wso2carbon.log file.
The xml for scheduled task is as follows
<task class="org.apache.synapse.startup.tasks.MessageInjector"
group="synapse.simple.quartz" name="testtask2">
<trigger count="1" interval="60"/>
<property name="proxyName" value="EslSfaOFAOMSOIntegrationPS" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="soapAction" value="operation" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="injectTo" value="proxy" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="to"
value="http://10.1.6.176:8280/services/EslSfaOFAOMSOIntegrationPS.EslSfaOFAOMSOIntegrationPSHttpSoap11Endpoint" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
<property name="message" xmlns:task="http://www.wso2.org/products/wso2commons/tasks">
<soapenv:Envelope xmlns:esl="esl" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<esl:operation/>
</soapenv:Body>
</soapenv:Envelope>
</property>
</task>
The complete error log is as follows
TID: [-1234] [] [2017-02-23 06:19:17,471] ERROR {org.apache.synapse.core.axis2.Axis2Sender} - Connection:keep-alive,Content-Language:en,Content-Length:0,Content-Type:,Date:Thu, 23 Feb 2017 06:19:17 GMT,Server:Oracle-Application-Server-11g,Set-Cookie:<oracle fusion url>; httponly; secure; path=/,X-ORACLE-DMS-ECID:005IImNkZMq3z005RzH7id0001U70002LZ,<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope> Unexpected error sending message back {org.apache.synapse.core.axis2.Axis2Sender}
org.apache.axis2.AxisFault: Transport out has not been set
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:432)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:222)
at org.apache.synapse.mediators.builtin.RespondMediator.mediate(RespondMediator.java:35)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:260)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:766)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:282)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:554)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:188)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:261)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Put <property name="OUT_ONLY" value="true"/> inside your EslSfaOFAOMSOIntegrationPS proxy.
And I think you can remove to property since the message is sent to proxy given in proxyName property.

AnonymousEndpoint When send email in WSO2 ESB

When I Try a service which send message to an email, It send 1 message each 30sec 3 or 4 times. The error message is:
Suspending endpoint : AnonymousEndpoint - last suspend duration was :
30000ms and current suspend duration is : 30000ms
Why endpoint is marked like anonumousEndpoint if the message arrive to receiver?
Solution is adding this line before :
<header name="To" action="remove"></header>
<property name="RESPONSE" value="true" scope="default" type="STRING"></property>

Xmpp ejabberd and add-user command

I have two ejabberd servers, one local one distant online on foobar.com.
Using xmpp pidgin console i can send iq stanzas for tests:
Local server hostname is eepc
<iq to='eeepc' from='greg#eeepc' id='get-registred-users-num-1' type='set'>
<command xmlns='http://jabber.org/protocol/commands' action='execute' node='http://jabber.org/protocol/admin#get-registered-users-num'/>
</iq>
<iq from='eeepc' to='greg#eeepc/3493331071251540036345753' id='get-registred-users-num-1' type='result'>
<command xmlns='http://jabber.org/protocol/commands' sessionid='2009-08-29T14:01:55.714639Z' node='http://jabber.org/protocol/admin#get-registered-users-num' status='completed'>
<x xmlns='jabber:x:data'>
<field type='hidden' var='FORM_TYPE'>
<value>http://jabber.org/protocol/admin</value>
</field>
<field type='text-single' label='Number of registered users' var='registeredusersnum'>
<value>7</value>
</field>
</x>
</command>
</iq>
Distant Server
<iq to='foobar.com' from='greg#foobar.com' id='get-registred-users-num-1' type='set'>
<command xmlns='http://jabber.org/protocol/commands' action='execute' node='http://jabber.org/protocol/admin#get-registered-users-num'/>
</iq>
<iq from='foobar.com' to='greg#foobar.com/36523779951251567671615394' id='get-registred-users-num-1' type='error'>
<command xmlns='http://jabber.org/protocol/commands' action='execute' node='http://jabber.org/protocol/admin#get-registered-users-num'/>
<error code='404' type='cancel'>
<item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
I don't understand why i get a , i could not see any particular options to tell the server to accept commands from remote ?
Maybe mod_configure is simply not loaded on the distant server.
You can check via lists:member(mod_configure, gen_mod:loaded_modules("foobar.com")). in an ejabberd admin shell.
I cannot imagine that this is about being a remote user, because no s2s connection is needed between foobar.com and greg#foobar.com.
Looking in the mod_configure.erl source code there seems to be an ACL check to make sure the configure adhoc commands are only allowed when the requester is on a user account has configure priv on that virtual host. By default I think they don't.
acl:match_rule(LServer, configure, From)
You may need to add something like...
{access, configure, [{allow, greg#foobar.com}]}.
...to your ejabberd.cfg file.