Sunday, July 3, 2016

One time download link for mobile app download in App Manager

In App Manager 1.2.0, one-time download link support for mobile applications has been introduced. Now every user who has been authorised to a particular mobile app (Android, IOS or webapp) can subscribe and generate one-time download link for mobile app binary.

In App Manager, a user can download/install mobile app via WSO2 Mobile Device Manager (More information is available here or he can directly download the binary. One time download link support is provided for both installation types. But here, I would illustrate how to generate and retrieve sharable one-time download link for direct binary download.

First, you need to obtain OAuth access token with 'appm:subscribe' scope (Please refer to App Manager documentation on OAuth access token generation). Then you need to get the application Id of the preferred mobile application that you need to download/install. For example, suppose we have an android mobile application in App Store, with appId '3cf028b6-ead6-49f4-a43f-84d384c00d5e'. Then use the obtained OAuth access token to generate a one-time download by accessing the app direct download REST API.

REST API        : http://localhost:9763/api/appm/store/v1.1/apps/mobile/id/{appId}/download
HTTP Method  : POST
HTTP Headers : Authorization: Bearer {access_token}

If you use CUrl as the REST client, below will be the one-time download link generation command.
curl -X POST 
-H "Authorization: Bearer 8cda473d-a40a-3ddb-b596-6eb967819ee0" 
"http://localhost:9763/api/appm/store/v1.1/apps/mobile/id/3cf028b6-ead6-49f4-a43f-84d384c00d5e/download"

When this particular API is accessed with authorised user access token,

  1. If the user subscription is not available, he will be subscribed to the mobile app
  2. App URL will be generated and returned with the response
The following is a sample one-time download URL returned with the response.


{
  "appUrl": "http://localhost:9763/api/appm/store/v1.1/apps/mobile/binaries/one-time/84855dc5-ddb6-4e8b-83e0-20f6c24d429b"
}
You can directly access the URL and download/install the app.

No comments:

Post a Comment

Whitelisting and Blacklisting IPs for APIs in API Manager

Most of the time we come across different scenarios where we need to, Whitelist an IP for an API (Limiting API access for a given IP only)...