When your web app or service needs to call cloud APIs of IoT Platform, you must first understand the usage instructions, the cloud-to-cloud interaction flow, how to obtain a unique cloud AppKey, and API call examples.
Usage notes
- Cloud APIs and apps use different AppKeys. However, they use the same access environment. For information about how to obtain a cloud AppKey, see the instructions later in this document.
- For security reasons, use HTTPS for all cloud API calls. HTTP is not recommended.
- All API calls must use the POST method.
Cloud-to-cloud call flow
When your web app or service calls a cloud API of IoT Platform, it interacts with the Alibaba Cloud IoT server-side. The following figure shows this flow.
The flow is as follows.
- Your cloud calls the Get cloud resource Token operation to request a Cloud Token from the Alibaba Cloud IoT server-side. The server-side returns the Cloud Token and its expiration time.
The Alibaba Cloud IoT server-side grants Cloud Tokens at the project level. Each project has a unique Cloud Token. Include the project ID when you request a Cloud Token.
- Your cloud uses the obtained Cloud Token to call a specific API on the Alibaba Cloud IoT server-side. The server-side then returns the result of the request.
- Before the Cloud Token expires, your cloud renews it by calling the Refresh cloud resource Token operation.
If a Cloud Token expires, call the Get cloud resource Token operation again to obtain a new Cloud Token and its expiration time.
Obtain a cloud AppKey
Follow these steps to obtain a unique cloud AppKey.
- Log on to the IoT Platform console.
- Find the project that you want to manage and click Project Settings.
- (Optional) If your account has not been authorized, the Permission Authorization dialog box appears. Grant permissions to the platform.
- In the Permission Authorization dialog box, click Confirm.
- On the Cloud Resource Access Authorization page, click Agree to Authorization.
- Click Set Data Synchronization. The Cloud API Call area displays the AppKey and AppSecret for the online environment.
Call examples
IoT Platform provides cloud API call examples in multiple languages. For more information, see How to call cloud APIs.