Version 9.6
 —  Virtualizing APIs Using the CentraSite Business UI  —

Obtaining Your API Keys and Access Tokens for Consumption

The following section describes how to fetch your API keys and access tokens that enable you to consume APIs.

Note:
To enable CentraSite to issue email messages, an administrator must first configure CentraSite's email server settings. For procedures, see the section Configuring the Email Server in the document Basic Operations.


Viewing Details of Your API Keys

If you will be the using the API key authentication and you have successfully registered as a consumer for an API, you should have received your API key details.

The CentraSite Business user interface enables users to view details of an API key in the following ways:

Using the Email Notifications

Once your API registration request is approved, CentraSite sends an automated email message containing details of the API key value and its usage to both the approver and consumer.

If you want to receive email messages of the API key, make sure:

Access your mailbox.

The information contained in the email message depends on whether you access the API as a consumer or the owner.

Using the API Details Page

You can use the following procedure to view the details of an API key via the API Details page.

Start of instruction setTo view the details of an API key

  1. In CentraSite Business UI, display the details page of the API whose key value want to view. For procedure, see the section Viewing Details for an API Proxy.

  2. In the API Details page, go to Advanced Information -> Consumer Overview profile.

    The information contained in this profile depends on whether you access the API as a consumer or the owner.

Using the User Preferences

Alternatively, you can use the following procedure to view the details of all your API keys via the User Preferences page.

Start of instruction setTo view the details of an API key

  1. In the CentraSite Business UI navigation bar, click the profile name.

    The User Preferences page appears.

  2. Display My Access Keys.

    This shows a list of your API keys in CentraSite.

    Note:
    The My Access Keys panel IS NOT VISIBLE if at least one API key is not available in your CentraSite registry/repository.

  3. Each entry in the API key list contains the following information:

    Additionally, you can do the following operations on the API key:

Top of page

Using Your API Keys for Consumption

RESTful APIs are often exposed over the open Internet for consumption. API providers need a mechanism to prevent unauthorized access to the API. One approach is to provision consumers with API keys. Those keys can be used as authentication tokens.

CentraSite API Management Solutions automatically generates API keys when consumers request to consume APIs. The API providers can view, approve and set expiration for API keys. This ensures that no consumer can access a protected API without a valid key.

API keys are verified at runtime to ensure that:

Note:
Throughout this section, the term "Virtual Alias" is also referred to as "API" or simply "API". The name can be used interchangeably.

This section provides information about consuming APIs that are published in the webMethods Mediator. If you are using a different kind of PEP, refer to its documentation for publishing procedures and information.

The API Consumption Model

To enable a consumer to consume an API, the following events must occur:

  1. The consumer sends a request to consume a specified API. The request must include the consumer's authentication credentials.

  2. CentraSite generates the API key for consumption of the API (the specific key generation steps depend on the configuration settings defined by the Provider of that particular API). Later, CentraSite prepares the API for publishing and invokes the API Key Generation policy on the Mediator. The consumer will use this API key in order to consume this API.

  3. The API Key Generation policy publishes the API in the Mediator.

  4. If the publication is successful, the API Key Generation policy returns a success message, including data that is pertinent to the published API. (This includes the API key that is required for consuming this API). If the publishing is unsuccessful, the deployer service returns a failure message.

  5. The consumer accesses the URL for API consumption, sends the API key as integral part of the HTTP request header or as a query string, and upon validation of the API key consumes the API.

  6. If the consumption is successful, the consumer uses the API. If the consumption is unsuccessful for some reasons of authentication, a 500 fault is returned.

How Does Mediator Evaluate Consumers at Run Time?

To determine the consumer from which an API consumption request was submitted, an API must have the policy governance rule defined with at least one Evaluate action. This action extracts a specified evaluator from an incoming request and locates the consumer defined by that identifier.

For example, if you configure the "Evaluate IP Address" action to evaluate consumers by IP address, Mediator extracts the IP address from a request's HTTP header and searches its list of consumers for the consumer that is defined by that IP address.

You can configure the Evaluate actions to evaluate consumers based on the following information in a request message.

Evaluator Description
IP Address The IP address from which the request originated.
Host Name The name of the host machine from which the request originated.
HTTP Authentication Token The user ID submitted by the requestor when it was asked to provide basic HTTP credentials (username and password).
WS-Security Authentication Token The WSS username token supplied in the header of the SOAP request that the consumer submitted to the API.
XPath The custom authentication credentials (tokens, or username and password token combination) supplied in the HTTP request header that the consumer submitted to the API.
Consumer Certificate The X.509 certificate supplied in the header of the SOAP request that the consumer submitted to the API.

How Does a Consumer Use the Generated API Key?

REST services rely on HTTP methods like GET, POST, PUT and DELETE to make request to an API provider, so the API keys are closely tied to these HTTP methods, where they are sent as part of these HTTP method requests.

CentraSite allows you to set API keys as part of the HTTP header or as the query component of an API request.

Important:
In the case where a consumer is sending a request with both credentials (HTTP header) and (query string), the HTTP header take precedence over the query string when the Mediator is determining which credentials it should use for the consumption.

Request Header

The API keys are passed as the HTTP header component of an API consumption request. The HTTP header corresponds to an array of header names to include for that particular API consumption.

The following example demonstrates a typical HTTP request with API keys that form the header value of the API Access URL.

x-CentraSite-APIKey:a4b5d569-2450-11e3-b3fc-b5a70ab4288a

Query String

The API keys are passed as the query component of an API consumption request.

The following example demonstrates a typical HTTP GET request with API keys that form a query string of the API Access URL.

http://localhost:5555/ws/RestAPI?APIKey=a4b5d569-2450-11e3-b3fc-b5a70ab4288a

Notice that the API keys are added to the path after a “?”, and specified as key-value pair.

What Happens When You Request for API Consumption?

When you request an API for consumption using the Access URL and the generated API key, CentraSite automatically validates the APIs run-time actions to ensure that any "Evaluate" action that appears in the policy governance rule of an API is validated with the consumer requesting for that API.

What Happens When Consumption Fails?

If the API consumption encounters a problem due to one or more of the following reasons, a 500 SOAP fault is returned.

Top of page

Fetching and Using Your OAuth2 Access Tokens for Consumption

If you will be using the OAuth 2.0 protocol and you have successfully registered as a consumer for an API, you should have received your OAuth2 client credentials (a client_id and client_secret).

Now you need to obtain an OAuth2 access token by passing your client credentials to the Mediator-hosted REST service mediator.oauth2.getOAuth2AccessToken. This service will provide an OAuth2 access token that you can subsequently include in your requests to call the API.

The service's input parameters are:

Ways for Clients to Provide the Inputs

There are three ways in which a client can provide the inputs for this service:

Note:
If a client provides the client_id and client_secret in both the Authorization header and the request body, the credentials given in the Authorization header are used.

Using HTTPS for Granting Access Tokens

For security reasons it is recommended to use HTTPS in your production environment. If you will be using HTTPS as the transport protocol over which the OAuth2 access tokens will be granted authorization, you must set the parameters pg.oauth2.isHTTPS and pg.oauth2.ports as described in the section Advanced Settings in the document Administering webMethods Mediator.

Responses Returned to Clients

Following are sample responses that are returned to the client:

Top of page