Accessing APIs

Objectives

After completing this lesson, you will be able to:
  • Create a bearer token for authentication.
  • Find a specific API in the SAP Business Accelerator Hub.

Creating a Bearer Token for Authenatication

Let’s look at how to generate a bearer token and navigate the SAP Business Accelerator Hub to find specific APIs.

How to Generate a Bearer Token

A bearer token is a type of access token used to authenticate users in a broad range of application types, including web apps and mobile apps. It is referred to as a "bearer" token because whoever "bears" or holds the token can access resources without the need for any further proof of identity.

In SAP Subscription Billing, a REST client can be used to generate a bearer token for authentication purposes. When interacting with SAP APIs, authentication is often required to ensure secure access to the resources. The REST client can typically be configured to make a request to the SAP authentication endpoint with the client's credentials, and upon successful authentication, the SAP system will generate and return a bearer token.

In this example, a REST Client called Bruno is used.

In SAP Subscription Billing, a REST client can be used to generate a bearer token for authentication purposes. When interacting with SAP APIs, authentication is often required to ensure secure access to the resources. The REST client can typically be configured to make a request to the SAP authentication endpoint with the client's credentials, and upon successful authentication, the SAP system will generate and return a bearer token.

In this example, a REST Client called Bruno is used.

Let’s generate a bearer token using Bruno! Watch the following video to begin.

Remember, bearer tokens are sensitive pieces of data. If they are intercepted or stolen, they can give full access to the user's sensitive data on the server. Therefore, it is essential to transfer them only over secure HTTPS connections to maintain safety.

The Service Key can be found in the SAP Business Technology Platform (BTP) where SAP Subscription Billing is also deployed. For this training, a Service Key is provided.

Generate a Bearer Token to Get Authorization for the APIs

Business Scenario

In our example, the bearer token is generated by a REST client tool called Bruno. The identity of a user or an application is typically validated with a username and password. In our case, authentication begins by entering a service key. The server validates this information and generates a bearer token.

Steps

  1. Get the following information:

    1. Client ID : ______________________________________________
    2. Client Secret: ______________________________________________
    3. Authentication URL: ______________________________________________
    1. Open the Service to get the information.

  2. In Bruno or Postman, create a new POST request. You can give it a name like "Get Bearer Token"

    1. Create the POST request in the named tool.

  3. Enter the Authentication URL in the request and add /oauth/token to the end.

    The URL should look like https://xxx.authentication.eu10.hana.ondemand.com/oauth/token.

    1. In the request, enter the Authentication URL.

    2. Add /oauth/token to the end.

  4. Enter the following data:

    KeyValue
    grant_typeclient_credentials
    client_idID from Service Key/Binding
    client_secretSecret from Service Key/Binding

    Bearer token: ____________________________________________________________________

    1. Enter the data at the Body tab.

    2. Choose Run.

      You will get the bearer token in the response section.

    3. Copy the token and use it in the next exercises.

      Note

      You have to copy the token without the " ". It is also important to know, that the tokens have an expiration duration. So if you will get an "unauthorized" error in the next lessons, make sure, to run the API request again.

    4. Note it down in the line above.

Finding Specific APIs in the SAP Business Accelerator Hub

Now that you have a better understanding of how to generate a bearer key, let’s look at how to find and access APIs in the SAP Business Accelerator Hub.

What is the SAP Business Accelerator Hub?

UI example of the SAP Business Accelerator Hub.

The SAP Business Accelerator Hub includes event content in addition to APIs. The SAP Business Accelerator Hub provides a comprehensive catalog of APIs, events, integration packages, and other integration content for various SAP solutions and services, including SAP Subscription Billing.

Within the SAP Business Accelerator Hub, you can explore and discover a range of event-driven capabilities, such as event definitions, event triggers, event schemas, and event-driven integration scenarios related to SAP Subscription Billing and other SAP products. This event content helps developers and integration teams understand how to leverage events for building event-driven architectures, orchestrate workflows, and enable real-time interactions between systems and applications.

The event content in the SAP Business Accelerator Hub is designed to complement the APIs and serve as a valuable resource for understanding and incorporating event-driven approaches into your integration projects. This may include details on specific events that can be utilized within SAP Subscription Billing, event payloads, event schemas, event triggering mechanisms, as well as guidelines on subscribing to and handling events within the context of the SAP ecosystem.

The SAP Business Accelerator Hub is a centralized cloud-based repository of APIs designed to ease the discoverability and implementation of SAP and partner APIs. The SAP Business Accelerator Hub is a one-stop-shop for all things related to SAP integration and presents a variety of services and APIs, prepackaged integration scenarios, processes, and other essential integration artifacts.

Developers can use the SAP Business Accelerator Hub to find, test, and understand available APIs. This access empowers developers to easily use APIs in their applications and deliver business solutions faster. The hub holds service APIs for a variety of SAP products, including SAP S/4HANA, SAP SuccessFactors, Concur, and more.

The SAP Business Accelerator Hub significantly simplifies the process of discovering, exploring, testing, and implementing SAP and partner APIs, providing a collaborative and efficient platform that enhances the integration of applications and data sources.

The SAP Business Accelerator Hub is an essential tool that supports digital transformation initiatives with a user-friendly interface that allows non-technical users to search and explore APIs.

Watch the following video to learn how to find an API that meets your needs.

The SAP Business Accelerator Hub simplifies the process of discovering, exploring, testing, and implementing SAP and partner APIs, providing a collaborative and efficient platform that enhances the integration of applications and data sources.

Summary

Now that you have explored REST APIs, service keys, bearer tokens, and the SAP Business Accelerator Hub, in the next unit you will examine how APIs directly relate to SAP Subscription Billing.