Skip to Content
Technical Articles

OpenConnectors-GoogleDrive Integration made simple with SAP CPI & SAP CP-OCN

In below blog would like to share how we can integrate Google Drive with SAP CPI using SAP Cloud Platform Open Connectors service.

Scenarios:

Will explain end to end scenarios of get and post file using POSTMAN http client.

Google Application Creation:

In order to consume Rest APIs of Google Apps we need to create application that communicates securely with SAP CP Open Connectors.

Step 1:

Login to https://console.developers.google.com and follow below steps

Step 2:

Create new project with valid logical name.

Step 3:

Click on the created project and navigate to APIs & Services dashboard.

Step 4:

Enable to Google Drive API to consume it in the application.

 

Step 5:

Once you enable the required API navigate back to Credentials tab of APIs & services to create credentials that can be used in OpenConnectors.

Once done save it.

Step 6:

Open Connectors Configuration:

Step 1:

Login to your Open Connectors account and search for Google Drive connector.Click on Authenticate

Step 2:

Click on view Optional Fields and enter  API key and Secret copied from Google Application.

Step 3:

Once you click on Create Instance button in previous step it will open new window to authenticate with your Google Credentials.Proceed with the same and click on allow application to access your google drive data.

Step 4:

Now you have successfully established the connectivity.Now click on Test in the API docs to make sure you are able to perform smoke test and able to copy the Authorization header & end point url which can be used in your SAP CPI iflow.

now fill the required details and click on execute button.

its time to see the result and copy the credentials.

Creation of IFlow [ get call from SAP CPI ]:

Create an IFlow like below to query the file from POSTMAN and get the file content back.

Step 1: 

Add communication channel of type HTTPS and give address like below.

Step 2: 

Add content modifier to delete all unwanted headers and set property containing file name with path which can be used in your receiver communication channel.

Step 3:

Add content modifier to set authorization header ( value copied from Open Connectors Step # 4 last screen ).

Step 4:

Add HTTP communication channel with below configuration ( url copied from your Open Connectors Step# 4 config ).

Time to Test your scenario:

Open POSTMAN and copy of the endpoint url of your IFlow ending with /getFile and copy paste the below XML in body.

<Root>
	<FilePath>/OpenConnectors/EDI_SAMPLE.txt</FilePath>
</Root>

Creation of IFlow [ Post call from SAP CPI ]:

Create an IFlow like below to post file from Postman and store it in Google Drive.

Note: As highlighted below Allowed Headers needs to updated with value content-type|fileName

Step 1: 

Add communication channel of type HTTPS and give address like below.

Step 2: 

Add content modifier to set property containing file name with path which can be used in your receiver communication channel.

 

Step 3:

Add content modifier to set authorization header ( value copied from Open Connectors Step # 4 last screen ).

Step 4:

Add HTTP communication channel with below configuration ( url copied from your Open Connectors Step# 4 config ).

Time to Test your scenario:

Open POSTMAN and copy of the endpoint url of your IFlow ending with /posttFile and follow below screen in order to set header containing file name with path & upload the file in form-data format with key “File”.

 

And when you click on send ,you are done with posting file to Google Drive with below response with a file in Google Drive folder.

Reference:

[ 1 ] – Open Connector Blog series

Hope this helps!

Regards,

Sriprasad Shivaram Bhat

 

 

 

 

7 Comments
You must be Logged on to comment or reply to a post.
  • Thank you so much for this blog Sriprasad. I followed the steps and with few trial I was able to do it. Your blogs are great help to us. Thanks and keep blogging. 🙂

    Regards,

    Binod

  • Hi Sriprasad,

    When providing the API key and API secret , I am getting the below error. Also i am not sure what is this auth.cloudelements.io url please help me to understand .

     

    https://auth.cloudelements.io/oauth, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit:

     

    Thanks and Regards,

    Vijay

     

    • Hello Vijay,

      Please check the OAuth Consent application whether you have properly given the url,

      Also images you have added in the above comment is not visible.

      Regards,

      Sriprasad Shivaram Bhat

    • Hi Vijay,

      It would probably the reason of authorization domain issue. Please check step 5 from Google app setup in this blog. I faced same issue and it resolved once updated properly

  • Hello Sri,

    Its a very nice blog. I have followed your steps and able to get the file from the open connectors but after i have configured the IFlow in CPI while triggering from postman i’m getting the error as 401 this means unauthorized my doubt is in the below URL(which we have copied from the cloud connectors get operation) upto where i have to give in the Authorization variable is it like from User to before Organization or else from User to end of the line means upto the end of the Organization …

    If i gave till the end of the Organization getting the error as HTTP 400 otherwise if i gave intermediate URL getting the error as http 401…in the postman apart from URL , Credentials , Body do we need to send any header parameters ?

    Plz help me i’m end of this scenario

     

    Thanks,

    Satish.