Keep getting unauthorized when registering devices in Azure Notification Hubs -


i have followed every example 't' , cannot azure notification hubs return other following 401 message: "malformedtoken: credentials contained in authorization header not in wrap format."

i have tried namespace access keys , notification hub keys no avail. have followed examples here: https://msdn.microsoft.com/en-us/library/azure/dn495630.aspx , have been unable work. changed account specific settings namespace, notification hub name , authorization key.

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;                  }              });

the value {myaccesskey} should like:

sharedaccesssignature sig=<signature-string>&se=<expiry>&skn=<keyname>&sr=<url-encoded-resourceuri> 

documentation constructing signature @ https://msdn.microsoft.com/en-us/library/azure/dn170477.aspx


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -