I'm developing a streaming application on Android using Azure Media Services. I followed instructions on their page (can't post more than 2 links). This is the the response I'm getting:
D/OkHttp: --> POST https://wamsprodglobal001acs.accesscontrol.windows.net/v2/OAuth2-13 http/1.1
D/OkHttp: Content-Type: application/x-www-form-urlencoded
D/OkHttp: Content-Length: 159
D/OkHttp: Host: wamsprodglobal001acs.accesscontrol.windows.net
D/OkHttp: Expect: 100-continue
D/OkHttp: Connection: Keep-Alive
D/OkHttp: Accept: application/json
D/OkHttp: "grant_type=client_credentials&client_id=<AccountName>&client_secret=<UrlEncodedPrimaryKey>&scope=urn%3aWindowsAzureMediaServices"
D/OkHttp: --> END POST (159-byte body)
I/art: Background sticky concurrent mark sweep GC freed 29299(2MB) AllocSpace objects, 14(268KB) LOS objects, 40% free, 5MB/9MB, paused 14.302ms total 58.113ms
D/OkHttp: <-- 400 Bad Request https://wamsprodglobal001acs.accesscontrol.windows.net/v2/OAuth2-13 (1028ms)
D/OkHttp: Cache-Control: private
D/OkHttp: Content-Type: application/json; charset=utf-8
D/OkHttp: x-ms-request-id: f6541a67-21c5-465b-9b36-96ef257980f1
D/OkHttp: request-id: f6541a67-21c5-465b-9b36-96ef257980f1
D/OkHttp: X-Content-Type-Options: nosniff
D/OkHttp: Strict-Transport-Security: max-age=31536000; includeSubDomains
D/OkHttp: Date: Fri, 09 Dec 2016 14:43:55 GMT
D/OkHttp: Content-Length: 254
D/OkHttp: {"error":"invalid_request","error_description":"ACS90011: The required field \u0027grant_type\u0027 is missing.\r\nTrace ID: f6541a67-21c5-465b-9b36-96ef257980f1\r\nCorrelation ID: e575a3ec-539e-4e72-82a1-ed9dc4c1a4b3\r\nTimestamp: 2016-12-09 14:43:55Z"}
D/OkHttp: <-- END HTTP (254-byte body)
Also tried to send the same request using Postman and successfully received the token.
In case someone's having the same problem, I used Retrofit on my Android app. The problem was because the @Body of the request is of type String so needed to be properly formatted. Here is the link on how to do it: https://futurestud.io/tutorials/retrofit-2-how-to-send-plain-text-request-body