WNS notification - receiving 404 even on valid token - windows-8

I am trying to push notifications to my windows app via WNS,
I get a 404 response everytime.
I have verified that the Channel URI is valid, because every time I launch the app, I get the channel URI and use that immediately for testing.
Here is the curl call I make
curl -i -d "<tile><visual><binding template='TileSquareText01'><text id='1'>tile one text</text></binding><binding template='TileSquareText02'><text id='2'>tile two text</text></binding></visual></tile>" -H "Authorization: Bearer EgAeAQMAAAAEgAAACoAAFQOHLfF3CMYK/IUs8MgTUFoS9vwOM4AFavJ3TLGAczjxBJNm02+rMlWFGYNWAefkuCw/Qg62++O+5GdrLRqQCdBSSI+cZPPXwOKk6lagOLDXNzd41hPMG9/NYi/Li1dHddMLLkPVWuZ6Te+t1ofOeL30PDA9p8JVEVDAX/CfLXGNAFoAjQAAAAAAL+oNSH9RuFB/UbhQ60gEAA8AMTIzLjIwMS4xMzUuNTMAAAAAAF4AbXMtYXBwOi8vUy0xLTE1LTItMTIxMTkzNzMyNS0yNTg0NzczMzMzLTE1ODE1OTA0OTYtNDE4NTk0OTY5OS0yNDEwMjc4ODgzLTM4NjU2MTI0NzAtOTM5MDAzNTk0AA==" -H "content-type: text/xml" -H "content-length: 190" -H "X-WNS-Type: wns/tile" "https://sin.notify.windows.com:443/?token=AgYAAAA/Bcry6hlYw8kOU5f4LHaS+dycP7UxcsT45eUcNlxfznxCltMK3emgIsHRAiRUk1X5VnQ0h0FC7fbOno+QI5aqUt2Q05foUg+XYeFvIcdsp6wwoMJ8VEjyOBzcT+z1JNM="
I get the following response
HTTP/1.1 404 Not Found
Content-Length: 0
X-WNS-MSG-ID: 1FD852615FA1E9DA
X-WNS-DEBUG-TRACE: SINWNS2012431
Date: Fri, 30 Nov 2012 06:57:46 GMT
I've checked the headers are all correct, test this by placing a wrong header and getting 400 Bad request instead.
Here is my app code for getting the Channel URI
get_channel_uri :function(){
var channel;
var pushNotifications = Windows.Networking.PushNotifications;
var channelOperation = pushNotifications.PushNotificationChannelManager.createPushNotificationChannelForApplicationAsync();
return channelOperation.then(function (channel) {
if(channel.uri){
// send to server
}
},
function (error) {
}
);
}
Any ideas what am I missing?

I found the solution on the MSDN forums.
I had not done the following
in Visual Studio 2012 going to "Project->Store->Associate App With the Store..." and select the app you have created. This then updates the manifest for you installing the correct certificates etc. After doing that, my app created a different notify url and everything started working.

Related

RabbitMQ Publish via Management HTTP API not_authorised but works in Web UI

I tried to publish a message to both the default exchange and also some other exchange via the HTTP Management API but I always get back an authorization error.
curl -i -u myuser:mypw -XPOST -d'{"properties":{},"routing_key":"my_key","payload":"my body","payload_encoding":"string"}' https://myinstance.rmq.cloudamqp.com/api/exchanges/vhost/myvhost/publish
HTTP/1.1 401 Unauthorized
Server: nginx/1.14.2
Date: Mon, 01 Apr 2019 05:27:10 GMT
Content-Type: application/json
Content-Length: 53
Connection: keep-alive
content-security-policy: default-src 'self'
vary: accept, accept-encoding, origin
{"error":"not_authorised","reason":"Access refused."}%
I tried it both on a self hosted RabbitMQ (installed via helm on k8s) and our CloudAMQP instance.
But if I login on the Management Web UI with the very same user then I can publish a message to the exchange and also consume from a queue.
I expect that the Management Web UI just uses the HTTP API for performing this actions so I am confused why it works when I do it via the UI.
Reading all vhost on the other hand works also with the HTTP API.
curl -i -u myuser:mypw https://myinstance.rmq.cloudamqp.com/api/vhosts
HTTP/1.1 200 OK
Can somebody explain to me whats going on there? What puzzels me the most is the fact that it works on the UI using the same user:pw.
I figured out the problem, I did use the wrong URL path.
For vhost: / and the default exchange it should be:
http://myinstance.rmq.cloudamqp.com/api/exchanges/%2F/amq.default/publish
In my case, using the CloudAmqp free plan, I needed to use my user name as vHost in rhe URL:
https://myinstance.rmq.cloudamqp.com/api/exchanges/[myrandomusernamefromfreeplan]/amq.default/publish

Docker Hub API v2 token authentication issue

Currently, I'm working on a very light version of Docker containers orchestrator and I have to be able to get image digest from public Docker Hub registry. I want to use Docker Registry API v2 for this purposes.
I'm trying to get authorization token using following API call:
curl https://auth.docker.io/token?service=index.docker.io&scope=repository:alpine:pull
... and I get a response like following:
{"token":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Y2Nlc3MiOltdLCJhdWQiOiJpbmRleC5kb2NrZXIuaW8iLCJleHAiOjE0NzQ1NDcyODMsImlhdCI6MTQ3NDU0Njk4MywiaXNzIjoiYXV0aC5kb2NrZXIuaW8iLCJqdGkiOiIzVTdCazF4dm9CLVA0MGJWVF9JSiIsIm5iZiI6MTQ3NDU0Njk4Mywic3ViIjoiIn0.516fS692WGHNi5Sc44iB8OFSLairrM6n1zNvVo5KXAxlsxsP4rE7VDmW5d0YqvTYeKfZAYIi9yEptx4xJlQ6DA"}
It seems that everything is okay and I'm trying to use obtained token for my next API call:
curl -i -H "Authorization: Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsIng1YyI6WyJNSUlDTHpDQ0FkU2dBd0lCQWdJQkFEQUtCZ2dxaGtqT1BRUURBakJHTVVRd1FnWURWUVFERXp0Uk5Gb3pPa2RYTjBrNldGUlFSRHBJVFRSUk9rOVVWRmc2TmtGRlF6cFNUVE5ET2tGU01rTTZUMFkzTnpwQ1ZrVkJPa2xHUlVrNlExazFTekFlRncweE5qQTFNekV5TXpVNE5UZGFGdzB4TnpBMU16RXlNelU0TlRkYU1FWXhSREJDQmdOVkJBTVRPMUV6UzFRNlFqSkpNenBhUjFoT09qSlhXRTA2UTBWWFF6cFVNMHhPT2tvMlYxWTZNbGsyVHpwWlFWbEpPbGhQVTBRNlZFUlJTVG8wVWtwRE1Ga3dFd1lIS29aSXpqMENBUVlJS29aSXpqMERBUWNEUWdBRVo0NkVLV3VKSXhxOThuUC9GWEU3U3VyOXlkZ3c3K2FkcndxeGlxN004VHFUa0N0dzBQZm1SS2VLdExwaXNTRFU4LzZseWZ3QUFwZWh6SHdtWmxZR2dxT0JzakNCcnpBT0JnTlZIUThCQWY4RUJBTUNCNEF3RHdZRFZSMGxCQWd3QmdZRVZSMGxBREJFQmdOVkhRNEVQUVE3VVROTFZEcENNa2t6T2xwSFdFNDZNbGRZVFRwRFJWZERPbFF6VEU0NlNqWlhWam95V1RaUE9sbEJXVWs2V0U5VFJEcFVSRkZKT2pSU1NrTXdSZ1lEVlIwakJEOHdQWUE3VVRSYU16cEhWemRKT2xoVVVFUTZTRTAwVVRwUFZGUllPalpCUlVNNlVrMHpRenBCVWpKRE9rOUdOemM2UWxaRlFUcEpSa1ZKT2tOWk5Vc3dDZ1lJS29aSXpqMEVBd0lEU1FBd1JnSWhBTzYxSWloN1FUcHNTMFFIYUNwTDFZTWNMMnZXZlNydlhHbHpSRDEwN2NRUEFpRUFtZXduelNYRHplRGxqcDc4T1NsTFFzbnROYWM5eHRyYW0xU0kxY0ZXQ2tJPSJdfQ.eyJhY2Nlc3MiOltdLCJhdWQiOiJpbmRleC5kb2NrZXIuaW8iLCJleHAiOjE0NzQ1NDcyODMsImlhdCI6MTQ3NDU0Njk4MywiaXNzIjoiYXV0aC5kb2NrZXIuaW8iLCJqdGkiOiIzVTdCazF4dm9CLVA0MGJWVF9JSiIsIm5iZiI6MTQ3NDU0Njk4Mywic3ViIjoiIn0.516fS692WGHNi5Sc44iB8OFSLairrM6n1zNvVo5KXAxlsxsP4rE7VDmW5d0YqvTYeKfZAYIi9yEptx4xJlQ6DA" https://index.docker.io/v2/alpine/manifests/latest
... and here what I've got:
HTTP/1.1 401 Unauthorized
Content-Type: application/json; charset=utf-8
Docker-Distribution-Api-Version: registry/2.0
Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:alpine:pull",error="invalid_token"
Date: Thu, 22 Sep 2016 12:27:54 GMT
Content-Length: 138
Strict-Transport-Security: max-age=31536000
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Name":"alpine","Action":"pull"}]}]}
Does anybody have ideas why token aouthentication fails for such simple flow?
The response in the Www-Authenticate header is trying to tell you what you need, although it could be more helpful.
First thing: the service you want is registry.docker.io.
Second thing: the repository name in the scope is incomplete. Official repositories only have a single-part name like alpine for the CLI, but in the registry it's properly called library/alpine.
So your token request should be:
curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/alpine:pull"
And then your image request is:
curl --header "Authorization: Bearer eyJh..." https://index.docker.io/v2/library/alpine/manifests/latest
And then you'll get the response.

Getting Response code 0 in API manager wso2 while Trying to connect Through enterprise Proxy

Well ,
i m hitting a simple PhoneVerify Request from my localhost which have enterprise proxy .
i have configured my Proxy setting using below link.
Can't access to production endpoint with WSO2 API Manager - entreprise proxy
But I m Getting The Same Response code 0 and Blank Response Body.
Here Is a the curl and Request URL :
Curl
curl -X GET --header "Accept: application/json" --header "Authorization: Bearer b9d93ac569bec1721716e1422b852b" "https://192.168.78.153:8244/phone/1.0.0/CheckPhoneNumber?PhoneNumber=8888888888&LicenseKey=0"
Request URL
https://192.168.78.153:8244/phone/1.0.0/CheckPhoneNumber?PhoneNumber=8888888888&LicenseKey=0
Response Body
no content
Response Code
0
Response Headers
{
"error": "no response from server"
}
[ base url: /phone/1.0.0 , api version: 1.0.0 ]
Since you are behind a proxy with port set through http.proxyPort, You have to use port 1234 instead of 8244.

Github API 502 error

I'm trying to add a user to a Github repository via their API, but I always get a 502 Bad Gateway error.
With curl I send a request like this (<...> replaced by a real owner, repo, etc.):
curl -i -H 'Authorization: token xxxxxxxxxx' -XPUT https://api.github.com/repos/<owner>/<repo>/collaborators/<username>
I also tried it with this url:
curl -i -H 'Authorization: token xxxxxxxxxx' -XPUT https://api.github.com/teams/<id>/members/<username>
As token I used a newly created Personal Access Tokens
But both times I get this back
HTTP/1.0 502 Bad Gateway
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html><body><h1>502 Bad Gateway</h1>
The server returned an invalid or incomplete response.
</body></html>
A GET on each URL works fine but a DELETE doesn't work either. So maybe it has to do with curl.
Quoting the reply from GitHub's support with changes in italic:
You're just getting trolled by HTTP and curl.
When you make a PUT request with no body, curl doesn't explicitly set a Content-Length header for that request. However, PUT requests with no Content-Length confuse servers and they respond in weird ways.
Can you please try explicitly setting the Content-Lenght header to 0, or supplying an empty body when making that request (so that curl can set the header for you)? You can accomplish that adding -d "" in your command.

Google Cloud Messaging 3rd party server gets "Missing Registration" error on sending message

I'm trying to send a message from 3rd-party server. When I send http request using curl command on shell, it works, but when I do the same thing with Ruby script, I keep on getting "Missing Registration" error. More specifically, when I type
curl --header "Authorization: key=MY_KEY" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"MY_REGISTRATION_KEY\"], \"data\":{\"data1\":\"data1val\"}}"
I get the following response
{"multicast_id":5609541310450656515,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1346184864739450%3083a1e3f9fd7ecd"}]}
, and the message is correctly received by Android device.
However, if I use the following script, the response from GCM server send error message like "Error=MissingRegistration". (using ruby version 1.9.3)
require "net/https"
require "uri"
uri = URI.parse("https://android.googleapis.com/gcm/send")
https = Net::HTTP.new(uri.host, 443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
https.start{|https|
request = Net::HTTP::Post.new(uri.path)
request["Authorization"] = "key=MY_KEY"
request["Content-Type"] = "application/json"
request.set_form_data({:registration_ids => ["MY_REGISTRATION_KEY"],
:data => {data1:"data1_val"}
})
response = https.request(request)
p response.body
p response.header
}
I'm feeling like there is some problem around char encoding. I defined charset in content-type header and tried, but the result was same.
Can anyone help me?
It's about encoding. You have to set request's encoding to UTF8.