的accessToken的Windows推送通知返回错误请求400 [英] AccessToken for Windows Push Notifications returns Bad Request 400

查看:168
本文介绍了的accessToken的Windows推送通知返回错误请求400的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助!想不通为什么通过MSDN给出这个简单的code不工作....

我使用作为的在windows通知使用该MSDN文章以获得访问令牌,但它返回错误的请求400

I am using the following code in GetAccessToken() as given in the this MSDN article to get the access token to be used in windows notifications, but it returns "Bad Request 400"

PACKAGE_SECURITY_IDENTIFIER,当应用程序与Windows应用商店仪表板注册获得CLIENT_SECRET值

PACKAGE_SECURITY_IDENTIFIER, CLIENT_SECRET are the values obtained when the app was registered with the 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);
}

任何帮助将是非常美联社preciated .......

Any help would be highly appreciated.......

推荐答案

我发现错误响应的原因。其实,这是错误的PACKAGE_SECURITY_IDENTIFIER和CLIENT_SECRET。

I found the reason for the error response. In fact it is the wrong PACKAGE_SECURITY_IDENTIFIER and CLIENT_SECRET.

不要输入值。由于相关的ASCII值不同。因此,它始终是更好地复制并直接粘贴。

DO NOT type the values. Because associated ASCII values differ. Therefore it is always better to copy and paste directly.

您可能会得到与简单code段的访问令牌。

You will probably will get the access token with the simple code snippet.

干杯

这篇关于的accessToken的Windows推送通知返回错误请求400的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆