After an API is published and you are authorized to call the API, you can select the simple authentication or signature authentication method to call the API. If you select simple authentication, you must add the AppCode in a request header. If you select signature authentication, you must add the AppKey and AppSecret in a request header. This topic describes how to obtain authentication information for calling an API and how to call an API.
Prerequisites
An API that you want to call is published to API Gateway. For more information, see Publish an API.
You must obtain the following information before you can call an API:
The parameter definition of the API that you want to call.
The app that you use to call the API. The app has a key pair that uniquely identifies you. The key pair consists of the AppKey and AppSecret.
The relationship between the API and the app. The app must be authorized to call the API. For more information, see API authorization.
Background information
API Gateway allows you to use SDKs to authorize apps to call APIs. You can authorize your own account, a user in your enterprise, or a third party to call APIs.
Procedure
Obtain the API.
You can use one of the following methods to obtain an API:
Purchase an API in Alibaba Cloud Marketplace. For information about how to view the list of APIs that you purchased, log on to the Alibaba Cloud Marketplace console.
Obtain the API authorization from the API provider. For information about how to view the APIs that you are authorized to call, log on to the API Gateway console.
Create an app.
In API Gateway, apps define the identities that you use to call APIs. Each app has a key pair that consists of AppKey and AppSecret, which are equivalent to an account and its password. For more information about how to create an app, see Create an app.
Obtain the required permissions to call the API.
Authorization refers to granting an app the required permissions to call an API. Your app must be granted the required permissions before it can be used to call an API.
The authorization method varies based on how you obtain an API. For more information, see API authorization.
Call the API.
You can send an HTTP or HTTPS request to call the API. Before you call the API, you can use examples of calling APIs in multiple languages in the API Gateway console to test the call. For more information, see Examples on calling APIs and Enable HTTPS for an API operation.
View the authentication information for calling APIs
Log on to the DataWorks console. In the left-side navigation pane, click DataService Studio. On the page that appears, select the desired workspace from the drop-down list and click Go to DataService Studio.
In the top navigation bar of the DataService Studio page, click the Service Management tab.
In the left-side navigation pane, click Call APIs.
On the Call APIs page, you can view or copy the authentication information that is required to call APIs based on your business requirements.