[英]Uploading to Azure Media Services with sas url using rest api
[英]C# Connecting to Azure Media Services Account using REST API
我正在嘗試按照此文檔https://azure.microsoft.com/zh-CN/documentation/articles/media-services-rest-connect-programmatically/獲取訪問令牌
我的代碼現在看起來像這樣:
string requestUrl = String.Format("https://MyAccessControlNamespace.accesscontrol.windows.net/v2/OAuth2-13");
string bodyURL = string.Format("grant_type=client_credentials&client_id=MyMediaServicesAccountName&client_secret=MyAccountKeyEncodedToUrl&scope=urn%3aWindowsAzureMediaServices");
var request = (HttpWebRequest)WebRequest.Create(requestUrl);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "application/json";
byte[] requestBodyBytes = new ASCIIEncoding().GetBytes(bodyURL);
Stream requestStream = await request.GetRequestStreamAsync();
requestStream.Write(requestBodyBytes, 0, requestBodyBytes.Length);
var response = (HttpWebResponse) await request.GetResponseAsync();
我也嘗試過使用HttpClient。 但是我總是收到400錯誤的請求錯誤...
我將非常感謝您的幫助/提示!
媒體服務訪問控制地址為https://wamsprodglobal001acs.accesscontrol.windows.net/ 。 它不是AD的訪問控制命名空間。
改成 :
string requestUrl = String.Format("https://wamsprodglobal001acs.accesscontrol.windows.net/v2/OAuth2-13");
確保您的媒體帳戶密鑰已編碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.