Friday, 19 June 2020

Access Microsoft Outlook email using Outlook Version 2.0 API


Summary:
This blog demonstrates the steps involved to access Microsoft Outlook email using Outlook Version 2.0 API's.


Use Case:
If you are a application developer then often there might be at times requirement to read email messages or the email attachments send to a particular account user. So, how could you achieve this? There are many approaches for this but the most simple one is to make use of Microsoft's Outlook Version 2.0 API's.

Assumption:
1. Office 365 or School or outlook account is a must.


Let's begin the demonstration...
First of all in order to access emails via API's we must register application on azure portal and then provide appropriate access for the application/ client and then access emails using REST API's.

App registration on Azure portal
Step 1:  Login to azure portal (link)

Step 2: Click on "Portal" as shown below 




Step 3: On search bar, search for "App registrations" as shown below





Step 4: Click on "New registration" button




Step 5: Fill the Application registration form as shown below

Redirect URI is optional here and the URL must be unique to the environment from where the API's are being called from.

Example: Callback URL for postman client is https://app.getpostman.com/oauth2/callback



Click on "Register" button once done.

NOTE:
1. For School or Office 365 accounts use account type as option 1. 
2. For outlook personal account select account type as option 2.


Step 6: Note down the Application or Client ID from the Overview page





Step 7: Click on "Certificates & secrets"




Step 8: Click on "New client secret"





Step 9: Fill the form as per your requirement



Click on "Add" button


Step 10: Copy the secret generated as this will be only visible at the time of creation of secret




Step 11: Click on "API permission" from the menu and then click on "Add a permission" button




Step 12: Click on "Microsoft Graph" -> "Delegated permissions" -> select "email" -> "Add permissions"




We are done with the "App registration" on Azure.


Testing Outlook API's using POSTMAN:

Step 1: I'll use API to list all the folders in my outlook email account as shown below

Method: GET
URL: https://outlook.office.com/api/v2.0/me/MailFolders
Authorization Type: OAuth 2.0


Click on "Get New Access Token"



Step 2: Fill the details relevant to your Azure app created in above steps in the OAuth 2.0 form

Click on "Request Token" -> sign in with your outlook account in next screen
Click on "Use Token"

Step 3:  Click on "Send" button



Hope this blog helped you with the procedure to register app on Azure and consume outlook API's. .

Let me know in comments section for any queries.


Know Yourself Blogs...


Tuesday, 5 May 2020

Import JavaScript libraries / jar to OIC Integration and build custom function

Summary:
In this blog i'm going to explain the procedure to import JavaScript libraries into the Oracle Integration Cloud (OIC) - Integrations and build custom solutions.

Use Case:
Sometime in projects there would be requirement for which there won't be any out of the box solution provided in OIC, So in such cases we can make use of java script libraries and import them to OIC and build custom solutions.

In this blog i'm going to show you how to achieve AES encryption using JavaScript libraries in OIC as an example to show library import.


Assumption:
1. OIC instance is already configured in Oracle Cloud and the environment should be up and running


Let's begin by first creating a jar containing AES JavaScript libraries and the JavaScript file containing our custom function

Steps to create jar containing JavaScript files:
1. Import and save below mentioned JavaScript libraries into your local computer
     i. AES.js
    ii. crypto-js.min.js
   iii. enc-utf8.min.js


 NOTE: Highlighted libraries are to be imported from their source or from GitHub repository.

2. As shown in above screenshot we need to write our custom JavaScript function in the file 'encryptAndDecryptMessage.js' as shown below as per the OIC library coding specification

   

3. Post writing custom function we may need to zip all 4 .js files (3 js library files and 1 custom js function file) as a jar using below command

         jar -cvf EncryptDecrypt.jar *.js

4.  EncryptDecrypt.jar will now be created in your local computer


5.  Login to OIC Integrations instance and then click on Libraries and then click on register
     



Select below option before saving the JavaScript function
    

   


5. Now goto any of your integrations and the custom function created in earlier steps will now be listed under user functions
    


   

Hope this blog helped you with the procedure to import JavaScript libraries or to create custom functions in OIC .

Let me know in comments section for any queries.


Know Yourself Blogs...

Saturday, 2 May 2020

Import OIC Integration or .iar file into the JDeveloper IDE

Summary:
In this blog i'm going to explain the procedure to import Oracle Integration Cloud (OIC) - Integrations project or .iar file into the Oracle JDeveloper IDE.

Importing .iar file into JDeveloper will be useful for someone who has extensive experience working in JDeveloper IDE especially for XSLT coding and someone who is not comfortable working on XSLT in notepad or on OIC browser based IDE for mappings.

Assumption:
1. OIC instance already configured in Oracle Cloud and the environment should be up and running
2. Integration is already built and available for export. If not refer here to create one.
3. JDeveloper IDE is already installed in computer.

Steps:
1. Export any Integration from OIC instance with the help of below navigation.
      i.   Click on Designer from the Integrations home menu
      ii.  Click on Integrations from the Designer menu
      iii.  Select the Integration to be exported and then click on export from the menu as shown below
 
.iar file will now be downloaded to your local computer.

2. Open JDeveloper and create one Service bus application as shown below
   

3. Now create one service bus project within the application created in earlier step as shown below


4.
Now import the .iar file downloaded earlier in to the service bus project using below navigation
File-> Import -> Service bus resources



5. In the next window click on magnifier lens icon in front of zip source and select the .iar file as shown below
Click Next and then Finish.

6. The .iar file will now be imported into the JDeveloper IDE as shown below. 


Hope this blog helped you with importing .iar file or Integrations into the Oracle JDeveloper IDE. 

Let me know in comments section for any queries.


Know Yourself Blogs...

Create REST Web Service using Oracle Integration Cloud (OIC) - Integrations

Summary:
In this blog i'm going to explain the procedure to create REST web service in Oracle Integration Cloud (Integrations) which will be used to expose the integration as a web service to external consumers.

We are going to create a web service in this blog which will accept first name and second name of user and output will be greeting as described below

INPUT      :  <first name> 
                    <second name>
OUTPUT  :  Hello <first name  second name>

HTTP Method: POST

Assumption:
1. OIC instance already configured in Oracle Cloud and the environment should be up and running
2. Login user has at- least developer privilege for OIC.


Let's begin by first creating a Trigger REST connection

Steps to Create REST Connection as Trigger:
1. Goto Connections page in OIC integration with the help of below navigation.
      a.  Login to OIC instance   (e.g:  <host:port>/ic/home/)
      b.  Click on Integrations from the home menu (i.e. if landed on to OIC homepage post login)
      c.  Click on Designer from the integration menu
      c.  Click on Connection from the Designer menu
      d.  Click on Create button as shown below


2. Search for REST in the search bar and select the REST adapter or connection as shown below
  

3. Give the connection name, identifier, role and description in the window for REST connection creation as shown below and then click on 'create' button.

   


 Below are few points to be noted about the connection parameters
         i. Name: 
             This can be any name suitable for project or any project specific identifier.
         ii. Identifier: 
             This field value is auto generated by OIC and is used as a reference for integration while consuming it during integration development or could be used for uniquely identifying the connection while using OIC API's for connections.
         iii. Role: 
            Trigger is used when the connection is used as entry point for integration or for the external consumers to consume the service built. 
            Invoke is used if the integration consuming this connection want to communicate with external SOAP web services or references.
            Trigger and Invoke is used if the connection is used both as a entry point as well as a reference for invoking SOAP web services.

4. In next screen click on 'Test' and 'Save' button and then close the connection page
   

We have now successfully created REST connection as Trigger to consume in our integration. 

Let's now build our web service

Steps to Create Integration to expose as a REST web service:
1. Goto Connections page in OIC integration with the help of below navigation.
      i.   Click on Designer from the integration menu
      ii.  Click on Integration from the Designer menu
      iii.  Click on Create button as shown below

2. In the pop up window fill the Name for integration, Description, Version, Keyword and Package details if any and then click on Create button  

3. Click on the '+' icon at the top of screen and select the trigger connection which we created in earlier steps
    


4. In the pop up screen give some meaningful name for the connection and then click on next 


5. Fill the details for 'resource URI', select http method to POST under action, select check boxes to configure request and response payload for the endpoint and then click on Next button
   

6. Select the request payload format to JSON from the list of values/ drop down and then click on inline as shown below
   

7. Paste the sample JSON request payload as shown below and click on OK button
   

8.  Select the response payload format to JSON from the list of values/ drop down and then click on inline as shown below
   

9. Paste the sample JSON response payload as shown below and click on OK button

10. Then keep everything to default and click next -> done.
11. The flow will look similar to as shown in below screenshot 
    

12. Click on 'Map' activity in the flow and map output as concatenation of Hello, First name and Second Name
   


13. Update Tracking variable and Activate the integration. 
    Updating tracking variable and activating integration is described here
   
14. Copy the resource URL and test the service from Postman or any of your preferred testing tool and validate the service built as shown below



Hope this blog helped you in building REST Web Service using Oracle Integration Cloud. 

Let me know in comments section for any queries.


Know Yourself Blogs...

Access Microsoft Outlook email using Outlook Version 2.0 API

Summary: This blog demonstrates the steps involved to access Microsoft Outlook email using Outlook Version 2.0 API's. Use Cas...