我已将每个示例都跟踪为“t”,并且无法让Azure通知中心返回除以下401消息之外的任何内容:“MalformedToken:授权标头中包含的凭据不是WRAP格式。”
我尝试过命名空间访问密钥和通知集线器密钥无济于事。我已经按照这里的示例进行了操作:https://msdn.microsoft.com/en-us/library/azure/dn495630.aspx并且无法使其工作。我更改了所有帐户特定的设置,如命名空间,通知中心名称和授权密钥。
var registrationXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<entry xmlns=\"http://www.w3.org/2005/Atom\">" +
"<content type=\"application/xml\">" +
"<GcmTemplateRegistrationDescription xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/netservices/2010/10/servicebus/connect\">" +
"<GcmRegistrationId>" + {GCMRegID} + "</GcmRegistrationId> " +
"<BodyTemplate><![CDATA[ {\"data\": { \"message\": \"$(msg)\" } }]]></BodyTemplate>" +
"</GcmTemplateRegistrationDescription>" +
"</content>" +
"</entry>";
$.ajax(
{
type: "POST",
url: "https://{myNamespace}.servicebus.windows.net/{myHubName}/registrations/?api-version=2015-01",
headers: { 'Authorization': '{myAccessKey}', 'Content-Type': 'application/atom+xml;type=entry;charset=utf-8', 'x-ms-version': '2015-01' },
data: registrationXML,
dataType: "xml",
contentType: "text/xml",
success: function (data) {
debugger;
},
error: function (xhr, ajaxOptions, thrownError) {
debugger;
}
});
答案 0 :(得分:2)
{myAccessKey}的值应如下所示:
SharedAccessSignature sig=<signature-string>&se=<expiry>&skn=<keyName>&sr=<URL-encoded-resourceURI>
构建签名的文档位于https://msdn.microsoft.com/en-us/library/azure/dn170477.aspx
答案 1 :(得分:1)
以下是创建授权令牌2小时的方法。
=
谢谢, Sateesh