我正在尝试从 MNS 获取用于推送通知的访问令牌,并且WebRequest.GetRequestStreamAsync()
每次都方法超时。有什么建议么?
参考:http: //msdn.microsoft.com/en-us/library/windows/apps/hh913756.aspx
下面是我使用的代码
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create("https://login.live.com/accesstoken.srf");
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
string postString = String.Format("grant_type=client_credentials&client_id={0}&client_secret={1}&scope=notify.windows.com",
SID,
SECRET_KEY);
byte[] data = Encoding.UTF8.GetBytes(postString);
Stream newStream = await webRequest.GetRequestStreamAsync();
newStream.Write(data, 0, data.Length);