...
- Log in to the API Publisher.
- Create two APIs by the names
TestAPI1
andTestAPI2
and publish them to the API Store. - Log in to the API Store. Click the APIs menu and note that the two APIs are visible in the APIs page.
- Subscribe to both APIs using the same application. You can use an existing application or create a new one.
Go to the My Subscriptions page and create an access token to the default application. - Click the APPLICATIONS menu, click the application that you used to subscribe to the API with (
DefaultApplication
in this example), go to its Production Keys tab, and re-generate its access token. By default, access tokens expire an hour after creation.application. Invoke both APIs using the access token you got in the previous step. We use cURL here. The command is,
Code Block curl -k -H "Authorization: Bearer <access token>" '<API URL>'
Be sure to replace the placeholders as follows:
- <access token>: Give the token generated in step 5
<API URL>: Go to the API's Overview tab in the API Store and copy the production URL and append the payload to it.
Here's an example:
Code Block curl -k -H "Authorization: Bearer f5aa6e4c3e592339a4a64f4a05c1eb8f1d4d097-ebcc-3f02-8d91-0bd4e882ffcd" 'https://gateway.api.cloud.wso2.com:8243443/t/companyncompanyn3/test1/1.0.0/CheckPhoneNumber?PhoneNumber=18006785432&LicenseKey=0'
You have subscribed to two APIs and invoked them successfully. Let's block one subscription and see the outcome.- Log back to the API Publisher.
- Click the Subscriptions menu to open the Subscriptions page. It Click MANAGE SUBSCRIPTIONS. It shows all APIs/applications that each user is subscribed to.
- Block subscription for
TestAPI1
using theDefaultApplication
. Select theproduction and sandbox
option and click the Block link. - Note that the Block link immediately turns to Unblock, allowing you to activate the subscription back at any time.
- Log back to the API Store.
Invoke the two APIs (
TestAPI1
andTestAPI2
) again.Note You might have to regenerate the access token for
DefaultApplication
as done in step 5, if the access token expiration time (1 hour by default) has passed since the last time you generated it. You can refresh the access token by going to the My Subscriptions page in the Store.Note that you can invoke
TestAPI2
again but when you invokeTestAPI1
, it gives a message that the requested API is temporarily blocked. Neither the API creator nor any subscriber can invoke the API until the block is removed.Tip Tip: You might still be able to invoke an API within 15 minutes after blocking a subscription, until the cache is renewed.
- Go to the My Subscriptions page Back in the API Store, click the APPLICATIONS menu, select the application that you used to subscribe to the API two APIs earlier, click its Subscriptions tab, and note that your subscription is now blocked.
Go back
You can go to the API Publisher
...
and unblock the subscription
...
anytime. You have subscribed to two APIs, blocked subscription to one and tested that you cannot invoke the blocked API.