【发布时间】:2017-12-22 18:32:24
【问题描述】:
请帮忙!!想不通为什么 MSDN 给出的这个简单代码不起作用....
我在 GetAccessToken() 中使用this MSDN article 中给出的以下代码来获取要在 Windows 通知中使用的访问令牌,但它返回“错误请求 400”
PACKAGE_SECURITY_IDENTIFIER、CLIENT_SECRET 是应用在 Windows Store Dashboard 注册时获得的值
string urlEncodedSid = HttpUtility.UrlEncode(PACKAGE_SECURITY_IDENTIFIER);
string urlEncodedSecret = HttpUtility.UrlEncode(CLIENT_SECRET);
string body = String.Format("grant_type=client_credentials&client_id={0}&client_secret={1}&scope=notify.windows.com", urlEncodedSid, urlEncodedSecret);
string response;
using (WebClient client = new WebClient())
{
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
response = client.UploadString("https://login.live.com/accesstoken.srf", body);
}
任何帮助将不胜感激......
【问题讨论】:
-
@ConradFrix - 嗯,我投票结束了你链接的问题。我们不应该同时关闭它们!
标签: asp.net push-notification windows-store-apps