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,
- If the user subscription is not available, he will be subscribed to the mobile app
- App URL will be generated and returned with the response
{ "appUrl": "http://localhost:9763/api/appm/store/v1.1/apps/mobile/binaries/one-time/84855dc5-ddb6-4e8b-83e0-20f6c24d429b" }
No comments:
Post a Comment