Azure Media Service is a great turn-key solution for your video-on-demand and live streaming needs. It’s has been well documented in the Azure official site, however, it’s still not much information talking about AMS Node.js SDK and the AMS REST API. So, I’m going to talk a little bit about it in this blog.
1.There’s no offical Node.js SDK yet
Now Azure Media Service provides the SDKs and tools below (abstract from official site):
- Media Services REST API
- One of the available client SDKs:
- Azure Media Services SDK for .NET,
- Azure SDK for Java, Azure PHP SDK,
- Azure Media Services for Node.js (This is a non-Microsoft version of a Node.js SDK. It is maintained by a community and currently does not have a 100% coverage of the AMS APIs).
- Existing tools: Azure Classic Portal or Azure-Media-Services-Explorer.
Michelle’s Node project covers many of the functions, but it’s still missing some functions of Live Streaming. So if you need to use some live streaming functions, you can definitely leverage this.
2. How to make a successful call to AMS REST API using Node
There are many ways that you can test the API first, one of these is using POSTMAN. Note that you have to have an Azure subscription to do this.
You can follow this information to get your token back:
URL: https://wamsprodglobal001acs.accesscontrol.windows.net/v2/OAuth2-13
Method: POST
Headers:
Content-Type: application/x-www-form-urlencoded
Host: wamsprodglobal001acs.accesscontrol.windows.net
Content-Length: 120
Expect: 100-continue
Connection: Keep-Alive
Accept: application/json
Body: (choose x-www-form-urlencoded, which means it will encode your parameters automatically)
grant_type: client_credentials
client_id: [YOUR_AMS_CLIENTID]
client_secret: [YOUR_AMS_CLIENTSECRETE]
and then you can use this access_token to operate AMS REST API.
if you want to implement it in Node.js, here are some tips that will save you some time.
a. if you follow the guide above and provide your header and body accordingly you might still encounter this error
{“error”:”invalid_client”,”error_description”:”ACS50012: Authentication failed.rnTrace ID: 621b507f-d2f5-4fc6-b208-9bafc83aba68rnCorrelation ID: 67435ae3-3f3f-485a-b58d-85f28eabf2c9rnTimestamp: 2016-01-06 08:32:42Z”}
so what to do then?
please modify the headers and body as below, then you should be able to get your token back. 
Header:
‘accept’: ‘application/json;odata=verbose’,
‘Content-Type’: ‘application/json;odata=verbose’,
DataServiceVersion: ‘3.0’,
MaxDataServiceVersion: ‘3.0’,
‘x-ms-version’: ‘2.5’
‘Content-Type’: ‘application/json;odata=verbose’,
DataServiceVersion: ‘3.0’,
MaxDataServiceVersion: ‘3.0’,
‘x-ms-version’: ‘2.5’
Body:
scope: ‘urn:WindowsAzureMediaServices’,
grant_type: ‘client_credentials’,
client_id: ‘[YOUR_CLIENT_ID’,
client_secret: ‘[YOUR_CLIENT_SECRETE]’
grant_type: ‘client_credentials’,
client_id: ‘[YOUR_CLIENT_ID’,
client_secret: ‘[YOUR_CLIENT_SECRETE]’
3.APIs regarding live streaming
Please refer this document to operation Channels, and Programs…etc
I’ll find time to blog about this API.
Hey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
ReplyDeleteLive Streaming SDk
Stainless Steel Magnets - titanium arts
ReplyDeleteIroning the Stainless Steel worrione Magnets casinosites.one (4-Pack). Made in Germany. The Titanium Arts Stainless Steel Magnets are an titanium flat iron alloy made communitykhabar of steel in stainless https://deccasino.com/review/merit-casino/ steel
Table video games like black jack are not almost as profitable 원 엑스 벳 – to the on line casino – as slots. Earn advantages like Free SlotPlay®, reductions for dining and accomodations, comps, entry into promotions, unique invites to particular events, and far more. Play a machine that has gone lengthy time|a very lengthy time} with out paying off — it as a result of|as a outcome of} of} hit.
ReplyDeleteThanks for adding it to my knowledge. You are wonderful writer. Your articles are very helpful and easy to understand.
ReplyDeleteGRE Coaching in Vadodara