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.

Use a Bearer Token for Authentication

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. Generate a bearer token to get authorization for the APIs.

    1. Obtain Client ID and Client Secret First. To get the credentials, check the System Setup Guide.

      You need to obtain the client ID and client secret from your SAP Subscription Billing account. These credentials are typically provided when you set up your account or application within the SAP system.

    2. Next, set up the POST request using a rest client tool such as Bruno. You need to set up a POST request to the SAP Subscription Billing API endpoint for generating a bearer token. The endpoint URL will typically be provided by SAP.

    3. Then add the body in the POST request. You need to add the necessary body content such as grant-type and Authorization. The body of the request should include the client ID and client secret in the form of key-value pairs.

    4. Select the Send button arrow to send the request to the SAP Subscription Billing API endpoint.

      Send the request once the POST request is set up with the proper body.

    5. Finally, retrieve the bearer token.

      If the request is successful, the SAP Subscription Billing API responds with a bearer token in the form of a JSON object. This token can then be used to authenticate and authorize your subsequent API requests for accessing SAP Subscription Billing resources.

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.

Log in to track your progress & complete quizzes