Skip to Content
Technical Articles

OAuth2SAMLBearerAssertion flow with SuccessFactors with Quovadis-SAP destination.


This is a follow-up article to the following mini series of blogs on the OAuth2SAMLBearerAssertion Flow with the SAP BTP Destination Service.


The focus of this instalment is to discuss how to fully automate the implementation and the deployment of the  OAuth2SAMLBearerAssertion flow with the Destination service APIs.

Scenario A.

Using the default Destination Service trust


That’s the scenario covered in my original post: OAuth2SAMLBearerAssertion Flow with the SAP BTP Destination Service. SuccessFactors.

Leveraging the Destination Service Trust service simplifies the implementation of the entire OAuth2SAMLBearerAssertion flow, making it sort of out-of-the-box.

However there is one caveat to it, namely the trust (=the public X509 certificate key) has to be manually downloaded from the DestinationService GUI on the SAP BTP side.

Let's see what it takes to use a custom X509 certificate key and 
whether the little inconvenience above is worth the effort below ?



Scenario B.

Using the SuccessFactors generated X.509 key pair

Indeed, the Destination Service certificate APIs allow to manage your own key-stores with certificates and have them assigned to destinations programmatically.

Let’s see how this can be done with a custom trust (certificate) generated by SFSF.

Putting it all together.

a. Steps on the SFSF tenant side:

  1. Goto Admin Center/Tools/Manage OAuth2 Client Applications
  2. Register/add new client application.
  3. Generate x509 certificate. Only the CN field is mandatory. The value you enter as CN will become the name of the issuer in the signed saml assertion
  4. Download the generated key pair into a local text file. You will need it later.
  5. Register the application.

Good to know:

  • the SFSF-generated key pair is in PKCS8 format and base64 encoded
  • both the encrypted private key and the public x509 certificate of the key pair are already flattened into single line strings


b. Next step is to convert the key pair into a keystore file format that will be accepted by the DestinationService.


Good to know:

  • I have only tested either .pfx and .p12 PKCS12 keystore formats so far. These are the most popular containers of the certificate key pairs (private+public keys).
  • Supported certificate file extensions are: “.jks”, “.crt”, “.cer”, “.der”, “.p12”, and “.pfx”. However please note regardless of the keystore format you must provide both the private and the public key in the key pair container.
  • Destination service certificates API requires the name of the keystore with one of the above extensions and the content of keystore file encoded into a base64-encoded string.
  • The name of the keystore file is  important as it is used as a hint towards the base64-encoded content.
  • I did not find it very intuitive and was initially expecting to be able to pass my private and public keys [as base64-encoded single line strings] into the API without the need of creating a keystore file. Nonetheless, despite this caveat, the API allows you to fully automate the process of uploading/updating/removing of the certificates and not having to do it manually from the Destination Service GUI.

Steps to create a key pair container :

  • prepare the private and public keys in a normalised PEM format.
    • base64-decode the PKCS8 private key into a string and then format the string into a Private Key PEM format (not exceeding 64 characters per single line),
    • Save it locally into a file:
      here goes a truncated private key content.
      please note each line does not exceed 64 characters
      ----BEGIN PRIVATE KEY-----
      -----END PRIVATE KEY-----
    • base64-decode the X.509 public key into a string and then format the string into a X.509 PEM format (not exceeding 64 characters per single line).
    • Save it locally into a file:
      here goes a truncated public key content:
      please note each line does not exceed 64 characters
      -----BEGIN CERTIFICATE-----
      -----END CERTIFICATE-----


  • create a PKCS12-formatted .pfx or .p12 keystore.
    • run the below openssl command to create a PKCS12-formatted pfx keystore as depicted below:
$ openssl pkcs12 -export -inkey Quovadis-SAP-pkcs8.pem \
-in Quovadis-SAP-x509.pem -out Quovadis-SAP.pfx
Enter Export Password:
Verifying - Enter Export Password:

Please make note of the password as you will need it later
in the destination definition.
    • base64-encode the Quovadis-SAP.pfx file into a string for instance:

########################## truncated #################################



Good to know:

  • In order to base64-decode the keys you may use the command line or any online tool of your choice.
  • the steps above could be automated with 3rd party APIs.


c. From now on you may use the certificate file encoded string with the DestinationService APIs.


a. GET subaccountCertificates API call:
obtain the list of all uploaded certificates (key pairs) present 
in your DestinationService instance.
b. POST subaccountCertificates API call:
add a new keystore to the Destination service vault.
c. you may again run the GET certificate or GET certificates 
API to make sure yours has been recorded.



Good to know:

  • Alternatively you might upload the .pfx keystore file into the DestinationService instance from the Destination Service UI.

d. Now it is time to create a new destination to the Quovadis-SAP OAuth application with our Quovadis-SAP.pfx keystore.


  • Prepare the json structure of the Quovadis-SAP destination.
  • To make it more efficient we can reuse the json structure from the previously set up Quovadis-SFSF destination or any other destination you may have already defined.
  • We will need to add new “KeyStorePassword” and the “KeyStoreLocation” properties and of course amend the apiKey, the clientKey and the user.


  "Name": "Quovadis-SAP",
  "Type": "HTTP",
  "URL": "$metadata",
  "Authentication": "OAuth2SAMLBearerAssertion",
  "ProxyType": "Internet",
  "KeyStorePassword": "<your key store password>",
  "tokenServiceURLType": "Dedicated",
  "audience": "",
  "companyId": "<SFSF tenant companyId>",
  "authnContextClassRef": "urn:oasis:names:tc:SAML:2.0:ac:classes:PreviousSession",
  "apiKey": "<Quovadis-SAP apiKey>",
  "KeyStoreLocation": "quovadis-sap.pfx",
  "clientKey": "<Quovadis-SAP apiKey>",
  "nameIdFormat": "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
  "SystemUser": "<you test user>",
  "tokenServiceURL": "<SFSF tenant>/oauth/token"
  • add your destination definition using the subaccountDestinations API calls as depicted below:


a. GET subaccountDestinations API call:
obtain the list of all destinations present in your DestinationService instance.
b. POST subaccountDestinations API call:
add our new Quovadis-SAP destination to the Destination service instance.
c. you may again run the GET destination to retrieve the newly 
created Quovadis-SAP destination


e. Use (=Find) the Quovadis-SAP destination to acquire the bearer access token as demonstrated below:

Find destination API call:


That’s all. Curious what is your take on the initial question of this instalment ?

Let’s see what it takes to use a custom X509 certificate key and whether the little inconvenience above is worth the effort below ?

best wishes

Browse my community blog posts


Additional resources. SAP Business API Hub sandbox environment.

Before you can configure the API hub sandbox environment you will need to have created an instance of the destination service.

Please refer to the following article on the details for the sandbox environment configuration with SAP API Business Hub.



Be the first to leave a comment
You must be Logged on to comment or reply to a post.