Skip to Content
Author's profile photo Andreas Krause

Implement Facebook login on SAP API Management (Part 1)

When I recently conducted an API Management Training, one of the questions was: Do we also support Facebook Login on API Management itself? When thinking about it, there were two voices in my head, the Architect’s voice telling me that this should be handled in the Identity Provider (i.e. SAP Cloud ID), the Developer’s voice was telling me to get started and subscribe to a Facebook developer account. Fortunately for this Blog, the Developer’s voice won.

I will describe what needs to be done to integrate API Management into the Facebook OAuth 2 login flow and to internalize the resulting OAuth 2 token, so that the same token can be used for Graph API and API Management. The provided code snippets and the proxy focuses more on getting the job done and not on (very valid) security concerns resulting from it.


The blog will be written in 3 stages. The first one (below) describes how to signup on Facebook. The 2nd and 3rd will focus on API Management itself.

Signing up as a Developer on Facebook

In order to use the Facebook APIs you need to signup as a developer and register your APP in Facebook (

Once signed-up you need to create an APP (the Facebook representation of API Management). This is done in the upper right corner of the screen:

Here you need to provide a name and a contact e-mail:

Like in API Management you need to select a product, which is called “Facebook Login”.

Now half the job is done. In the settings of our newly registered Facebook Login App we will now have to enable “Client OAuth Login” and provide a redirect URI. The theory behind this can be found in the Official OAuth 2 specification (

The redirect URI should point to an API Proxy on your API management instance. In this proxy, where we will later receive the Authorization Code from Facebook and exchange it for a Facebook Bearer Token. This token will enable us to act on behalf of the user, using the Graph API. If you don’t know the redirect URI at this point in time, just set it to any valid URI and change it later on.

In the next step we need to make the API public. This is necessary so that users other than yourself can authorize API Management:

Now we need to collect our App ID and Secret. This is done in the Dashboard:

Now we have all the the necessary things to start building our API Proxy:

  1. Redirect URI (Can be changed later)
  2. App ID
  3. App Secret

With this we can move to part 2 (


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Mihai Dipsan
      Mihai Dipsan

      Hello Andreas,

      I was redirected to your article by your colleague Sven Huberti.

      I am trying to call an API proxy in an ios application and I want to use the OAuth security mechanism.

      I tried the solution presented in the article of your colleague:

      However it does not work for me.

      I am trying to use the OAuth2Swift class from the Swift framework for ios (xcode).

      However I need an authorizeUrl, accessTokenUrl and a CallbackUrl to perform the api call.

      I do not know where to find these Urls.

      I have also tried to use the OAuth 2.0 standard service from SAP Cloud Platform but I haven't figured it out how should be configured for SAP API Management.

      Can you help me please?

      Best Regards,

      Mihai Dipsan


      Author's profile photo Andreas Krause
      Andreas Krause
      Blog Post Author

      Hi Mihai,

      I am not a Swift/iOS Developer myself, hence I don't know the API. However if you read through you should have a fair understanding about OAuth2 which should help you getting started to invoke an API that is protected with the mechanism above.


      Regards Andreas