This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Using the Gmail Connector
In this tutorial, you use the Gmail connector to send an email containing the response received from SettlePaymentEP in the previous tutorial.
See the following topics for a description of the concepts that you need to know when creating WSO2 EI artifacts:
Before you begin,
Install Oracle Java SE Development Kit (JDK) version 1.8.* and set the JAVA_HOME environment variable.
Download the WSO2 EI ZIP file from here, and then extract the ZIP file.
The path to this folder will be referred to as<EI_HOME>through out this tutorial.Select and download the relevant EI tooling ZIP file based on your operating system from here and then extract the ZIP file.
The path to this folder will be referred to as<EI_TOOLING>through out this tutorial.For more detailed installation instructions, see the Installing Enterprise Integrator Tooling.
If you did not try the Storing and Forwarding Messages tutorial yet, open the WSO2 EI Tooling environment, click File, and then click Import. Next, select Existing WSO2 Projects into workspace under the WSO2 category, click Next and upload the pre-packaged project. This contains the configurations of the Storing and Forwarding Messages tutorial so that you do not have to repeat those steps.
Download the MSF4J service from here and copy the JAR file to
<EI_HOME>/wso2/msf4j/deployment/microservicesfolder. The back-end service is now deployed in the MSF4J profile of WSO2 EI.
Let's get started!
- 1 Setting up the message broker profile
- 2 Creating the credentials for using the using the Gmail Connector
- 3 Importing the Gmail Connector into EI-Tooling
- 4 Creating the Deployable Artifacts
- 5 Packaging the artifacts
- 6 Starting the Message Broker runtime
- 7 Starting the MSF4J profile
- 8 Starting the Integrator runtime and deploying the artifacts
- 9 Sending requests to WSO2 EI
Setting up the message broker profile
The message broker profile (which is an instance of WSO2 Message Broker) is shipped with the WSO2 EI product distribution. You need to enable the following configurations to be able to store messages in the broker profile.
Open the
<EI_HOME>/conf/jndi.properties fileand add the following line after thequeue.MyQueue = example.MyQueueline:queue.PaymentRequestJMSMessageStore=PaymentRequestJMSMessageStoreCopy the following JAR files from the
<EI_HOME>/wso2/broker/client-lib/directory to the<EI_HOME>/lib/directory.andes-client-3.2.13.jargeronimo-jms_1.1_spec-1.1.0.wso2v1.jarorg.wso2.securevault-1.0.0-wso2v2.jar
Creating the credentials for using the using the Gmail Connector
As the email sender, navigate to the URL https://console.developers.google.com/projectselector/apis/credentials and log in to your google account.
If you do not already have a project, create a new project and navigate to Create Credential -> OAuth client ID.
Select the Web Application option and create a client. Provide https://developers.google.com/oauthplayground as the redirect URL under Authorized redirect URIs and click on Create. The client ID and client secret will then be displayed.
Click on the Library on the side menu, and select Gmail API. Click enable.
Follow these steps to automatically refresh the expired token when connecting to Google API:
Navigate to the URL https://developers.google.com/oauthplayground and click on the gear wheel at the top right corner of the screen and select the option Use your own OAuth credentials. Provide the client ID and client secret you previously created and click on Close.
Now under Step 1, select Gmail API v1 from the list of APIs and check all the scopes listed down and click on Authorize APIs. You will then be prompted to allow permission, click on Allow.
In Step 2, click on Exchange authorization code for tokens to generate an display the access token and refresh token.
Importing the Gmail Connector into EI-Tooling
Right click on Sample Services in the Project Explorer and Select Add or Remove Connector. Then select Add Connector and click Next.
Select Connector Store location and click on Connect to connect to WSO2 Connector store and scroll down and select Gmail from the list of connectors.
Click Finish.
The connector is now downloaded into your Tooling environment and the connector operations will be available in the Gmail Connector palette.
Let's use these connector operations in the configuration.
Creating the Deployable Artifacts
The connector operations are used in the PaymentRequestProcessingSequence. Select this sequence, and do the following updates:
Add a Property Mediator just before the Call mediator to retrieve and store the patient's email address.
With the Property mediator selected, access the Properties tab of the mediator and fill in the information in the following table:
Add another Property mediator just after the Log mediator to retrieve and store the response sent from SettlePaymentEP. This will be used within the body of the email.
With the Property mediator selected, access the Properties tab and fill in the information in the following table:
Drag and drop the init method from the Gmail Connector palette adjoining the Property mediator you added in the previous step.
With the init method selected, access the Properties tab and fill in the information in the following table:
Add the sendMail method from the Gmail Conector palette and access the Properties tab and fill in the information in the following table:
The updated PaymentRequestProcessingSequence should now look like this:
Save the updated sequence configuration.
Right click on SampleServicesConnectorExporter and navigate to New -> Add/Remove Connectors and select Add connector and click on Next. Select Workspace to list down the connectors that were added.
Select the Gmail connector from the list and click OK and then Finish.