Skip to Content
Technical Articles
Author's profile photo Sriprasad S Bhat

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

 

 

 

 

Assigned Tags

      16 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Karthik Bangera
      Karthik Bangera

      Hi Sri,

      Thanks for the detailed blog. A great way to kick start 2019 ?

      Regards,

      Karthik

      Author's profile photo Sharma Ashwini
      Sharma Ashwini

      Thanks Sri..

      Good start of 2019 🙂 Keep blogging .

      Regards,

      Ashwini

       

       

      Author's profile photo Binod Mondal
      Binod Mondal

      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

      Author's profile photo Vijay Kapuganti Kumar
      Vijay Kapuganti Kumar

      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

       

      Author's profile photo Sriprasad S Bhat
      Sriprasad S Bhat
      Blog Post Author

      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

      Author's profile photo Anil Yakkali
      Anil Yakkali

      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

      Author's profile photo Satish Kumar Goli
      Satish Kumar Goli

      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.

       

      Author's profile photo shashank tiwari
      shashank tiwari

      Hi Sriprasad,

       

      while giving domain as auth.cloudelements.io I'm getting  "Invalid domain: must be a top private domain" error and it's not allowing me to save. Could you pls help with this?

      Author's profile photo Sriprasad S Bhat
      Sriprasad S Bhat
      Blog Post Author

      Hello Shashank,

      Below url in domain should work.

      cloudelements.io

      Redirect Url should be below.

      https://auth.cloudelements.io/oauth

      Regards,

      sriprasad Shivaram Bhat

      Author's profile photo shashank tiwari
      shashank tiwari

      Hi Sriprasad,

      Thanks for your helping out.

      Author's profile photo Andrea Nucifora
      Andrea Nucifora

      Hello Sriprasad,

      thank you very much for your blog, it was very helpful!

      Do you have any suggestions regarding posting files to a Google Team Drive?

      Checking for the documentation I can see that the option "teamDriveId" is available for Getting files from Drive, but we don't have the same option for the POST.

      Do you know how it is possible to do it?

      Thanks

      Andrea

      Author's profile photo pallavi chaudhury
      pallavi chaudhury

      Hi

       

      Im getting 502 error when following iflow1 via postman

      Author's profile photo Shiva Prasad Narahari
      Shiva Prasad Narahari

      Hi Sriprasad,

      I need to send a CSV file from SFTP to Google drive.

      If I follow this approach this works ?

      Or

      Should i convert the CSV file data to Form data in CPI ?

      Can you suggest me a good way to do this?

       

      Thanks

      Shiva

      Author's profile photo Jesus Alvarez
      Jesus Alvarez

      Hi Sriprasad S Bhat

      Thank you very much for the compatibility information in this blog, In my case I want to ask you about how I can manage authentication in SAP Cloud CF Integration using a Google service account. In the company we have a custom application that manages your authentication with Google service accounts. In order to connect to the microservices, I must generate an access token with the Google service account. I am currently doing this with Groovy and some additional libraries, but I think this would not be the best practice, can you help me with your recommendations in this case.
      Regards
      Author's profile photo Dinesh M
      Dinesh M

      Hi Sriprasad,

      Is it possible to post PDF file to GDrive?

      Thanks,

      Dinesh

      Author's profile photo R B
      R B

       

      Hi Sriprasad,

      Very good post.

      I have one question. If we use directly the open connectors adapter for gdrive , then why we cant use path=${property.name} . We need to give the path as hardcoded path=/homework/file1.txt

      In that case if we se uopenconnectors adapter, it does not take path=${property.name} gives error