Introduction
In this part we will see how to create an API Provider and API proxy with our Open Connector instance created in the
previous part.
Create an API Provider and API Proxy in SAP API Management
Step - 1: Create an API Provider using our google drive open connector instance
Open the API Portal from SCP -> Services -> API Management - > Access API Portal
Navigate to
Configure from menu
Select
API Provider - > Create
Give provider name and select connection tab to provide configuration details
Select Type as
Open Connectors and fill other required information and save the provider.
Organizational secret and user secret can be fetched from open connector portal by clicking the user icon at bottom of the page
Organizational Secret - To identify your organization and route to concerned system
User Secret - To identify the user
Element Secret - It is specific to each instance
Step - 2: Create API Proxy using created API Provider
Navigate to Develop in Menu and select API Proxy tab then create
Select the API Provider from drop down and provide URL as
/elements/api-v2/
Once it is created, deploy the proxy.
Step -3 : Add KVM for default Open Connector policy
Open Connector policy in post flow is a default policy that cannot be modified so we need to create a KVM entry at proxy level - Refer
here
This can be posted using Postman / SOAP UI / any other rest client
I. Open Postman and do head call to get CSRF token
Headers :
Authorization : Basic <encodedCredentials>
X-CSRF-Token : fetch
II. Do post call with fetched CSRF token in header and body as below
Headers :
Authorization : Basic <encodedCredentials>
X-CSRF-Token : <fetched token>
Request Body:
{
"name": "apim.oc.instance.token",
"scopeId": "Googledrive",
"scope": "APIPROXY",
"isEncrypted": true,
"genericKeyMapEntryValues": [
{
"name": "default", //key name
"mapName": "apim.oc.instance.token",
"value": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", //instance/Element token
"scopeId": "Googledrive",
"scope": "APIPROXY"
}
]
}
Instance token can be fetched from Open connector instance
Internally Open Connector policy is fetching the Organizational Secret, User Secret from Provider configuration followed by fetching the Element token from
apim.oc.instance.token KVM and concatenating all in below format and assigning to request headers.
User <user secret>, Organization <Organizational secret>, Element <instance token>
Now we are all set with API proxy, lets get into action.
Step - 4 : Testing
Here we are going to download a file from my google drive through our proxy
Now file downloaded to our system. If you are using this API in any of the programming languages, then response will be in binary stream that can be created as a file.
hope this blog series provided idea about Open connector and API Proxy.