Not receiving push notification with encrypted payload - node.js

I've been following the document over in this resource to get Push-Notifications sending to a browser with a payload. (Chrome 53.0.2785.116 m).
I'm using the Nodejs Crypto library to generate the keys and they all pass the verification test created by the folks at Google.
I can send and receive a Push-Notification when I do not include the encrypted payload. As soon as I attach the 'raw_data' tag with the encrypted payload the browser no longer receives the Push-Notification (although Curl still comes back with a 'success(1)' response)
Below is the Curl message with and without the payload.
Without Payload -
curl --header "TTL:86400"
--header "Authorization: key=API_KEY"
--header "Encryption: salt=E2oUmcFWbb41wk5DuTbuoA"
--header "Crypto-Key: dh=SERVER_PUBLIC_KEY"
--header "Content-Encoding: aesgcm"
--header "Content-Type: application/json"
https://android.googleapis.com/gcm/send -d
"{\"registration_ids\":[\"CLIENT_KEY\"],\"content_available\":true}"
--insecure
With Payload -
curl --header "TTL:86400"
--header "Authorization: key=API_KEY"
--header "Encryption: salt=E2oUmcFWbb41wk5DuTbuoA"
--header "Crypto-Key: dh=SERVER_PUBLIC_KEY"
--header "Content-Encoding: aesgcm"
--header "Content-Type: application/json"
https://android.googleapis.com/gcm/send -d
"{\"registration_ids\":[\"CLIENT_KEY\"],\"raw_data\":\"UnGSxqxfy9yDwPgCVeXJibQyPX8Hz28\",\"content_available\":true}"
--insecure
Both return a success message
{"multicast_id":9197002368280649941,
"success":1,"failure":0,
"canonical_ids":0,
"results":[{"message_id":"0:1474618927798802%bc86b90cf9fd7ecd"}]}
but the latter is not received by the browser.
We're now into the fourth day of head scratching. Any help would be great.

Related

How do I interact with the hackage API using curl?

There are sparsely documented methods here. This page just mentions there's an API, and links to the hackage-security library which 5min poking around doesn't help me figure out how to form an http request to the (which?) server
The following just get me a stub html file:
$ curl -H "Accept: application/json" hackage.org/package/aeson/
$ curl -H "Accept: application/json" hackage.org/api/package/aeson/
old related: Does Hackage have an API?
You have the base URL wrong. It's https://hackage.haskell.org/.
curl -H 'Accept: application/json' https://hackage.haskell.org/package/aeson
yields the output
{"0.1.0.0":"normal","0.10.0.0":"deprecated","0.11.0.0":"normal","0.11.1.0":"normal","0.11.1.1":"normal","0.11.1.2":"normal","0.11.1.3":"normal","0.11.1.4":"normal","0.11.2.0":"normal","0.11.2.1":"normal","0.11.3.0":"normal","0.2.0.0":"normal","0.3.0.0":"normal","0.3.1.0":"normal","0.3.1.1":"normal","0.3.2.0":"normal","0.3.2.1":"normal","0.3.2.10":"normal","0.3.2.11":"normal","0.3.2.12":"normal","0.3.2.13":"normal","0.3.2.14":"normal","0.3.2.2":"normal","0.3.2.3":"normal","0.3.2.4":"normal","0.3.2.5":"normal","0.3.2.6":"normal","0.3.2.7":"normal","0.3.2.8":"normal","0.3.2.9":"normal","0.4.0.0":"normal","0.4.0.1":"normal","0.5.0.0":"normal","0.6.0.0":"normal","0.6.0.1":"normal","0.6.0.2":"normal","0.6.1.0":"normal","0.6.2.0":"normal","0.6.2.1":"normal","0.7.0.0":"deprecated","0.7.0.1":"deprecated","0.7.0.2":"deprecated","0.7.0.3":"deprecated","0.7.0.4":"normal","0.7.0.5":"deprecated","0.7.0.6":"normal","0.8.0.0":"deprecated","0.8.0.1":"deprecated","0.8.0.2":"normal","0.8.1.0":"normal","0.8.1.1":"normal","0.9.0.0":"normal","0.9.0.1":"normal","1.0.0.0":"normal","1.0.1.0":"normal","1.0.2.0":"normal","1.0.2.1":"normal","1.1.0.0":"normal","1.1.1.0":"normal","1.1.2.0":"normal","1.2.0.0":"normal","1.2.1.0":"normal","1.2.2.0":"normal","1.2.3.0":"normal","1.2.4.0":"normal","1.3.0.0":"normal","1.3.1.0":"normal","1.3.1.1":"normal","1.4.0.0":"normal","1.4.1.0":"normal","1.4.2.0":"normal","1.4.3.0":"normal","1.4.4.0":"normal","1.4.5.0":"normal","1.4.6.0":"normal","1.4.7.0":"normal","1.4.7.1":"normal","1.5.0.0":"normal","1.5.1.0":"normal","1.5.2.0":"normal","1.5.3.0":"normal","1.5.4.0":"normal","1.5.4.1":"normal","1.5.5.0":"normal","1.5.5.1":"normal","1.5.6.0":"normal","2.0.0.0":"normal","2.0.1.0":"normal","2.0.2.0":"normal","2.0.3.0":"normal"}

HTTP post request?param=PARAM vs --data-urlencode

i am just querying my InfluxDB and i made it work, but i never did web so i am not so experienced with http protocol. I need to do curl request.
This one works fine:
curl -X POST http://localhost:8086/api/v2/query?orgID=12345678 --header "Authorization: Token MYTOKEN" --header "Content-Type: application/vnd.flux" --data-binary 'from(bucket:"MYBUCKET") |> range(start: -55m) |> yield()'
But this does not and i dont understand why, i thought it is the same thing just differently put.
curl -X POST http://localhost:8086/api/v2/query --data-urlencode "orgID=12345678" --header "Authorization: Token MYTOKEN" --header "Content-Type: application/vnd.flux" --data-binary 'from(bucket:"MYBUCKET") |> range(start: -55m) |> yield()'
I guess no need for u to understand Influx to help me, I post this question after an hour of research and I just dont have time for this right now, can someone please just explain the concept to me? I can make it work obviously but this frustrates me since i thought its the same thing.
Thanks four the time, Q.
The mistake - is that you sends two payloads. The first example contains orgId as url parameter. In second orgId sent like payload and also sent data with influx query.
curl -X POST http://localhost:8086/api/v2/query
--data-urlencode "orgID=12345678" <-- FIRST PAYLOAD
--header "Authorization: Token MYTOKEN" --header "Content-Type: application/vnd.flux"
--data-binary 'from(bucket:"MYBUCKET") |> range(start: -55m) |> yield()' <-- SECOND PAYLOAD
And when you send such a request, it just takes the last payload

excel webservice http header

I am wondering if there is a way to include http header in excel WEBSERVICE function.
I am trying to use an API witch need a Authorization: Bearer ACCESS_TOKEN :
curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer ac004670-8f66-340a-b4d0-312b585d8cb3' 'https://api.insee.fr/metadonnees/V1/codes/nafr2/sousClasse/84.11Z'

How to use azure translator with authorization token?

I want to use azure translator service with the Authorization token. There are plenty of resources explaining how to do it with subscription key but I could not found any resource explaining the use of authorization token. I can get the authorization token but when I send a request with it, the response status code is 401.
This is how I send the request:
curl POST 'https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--data-raw '[{'\''Text'\'':'\''Hello World!'\''}]'
If you want to call Text Translation API with authentication token, please refer to the following steps
Get a token. If your service is global, the endpoint is https://api.cognitive.microsoft.com/sts/v1.0/issueToken
curl -v -X POST \
"https://YOUR-REGION.api.cognitive.microsoft.com/sts/v1.0/issueToken" \
-H "Content-type: application/x-www-form-urlencoded" \
-H "Content-length: 0" \
-H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY"
Besides, please note that an authentication token is valid for 10 minutes. The token should be reused when making multiple calls to the Translator. However, if your program makes requests to the Translator over an extended period of time, then your program must request a new access token at regular intervals (for example, every 8 minutes).
Call API
curl -X POST 'https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=de' \
-H 'Authorization: Bearer YOUR_AUTH_TOKEN' \
-H 'Content-Type: application/json' \
--data-raw '[{ "text": "How much for the cup of coffee?" }]' | json_pp
For more details, please refer to here and here.

How to send file content as string in data raw payload using cURL post request

Below is my curl query to send the post request
in the "payload" key of the json data i need to send file that is 1 MB of text data as values. Instead of copy past the whole text as string this should take the text as string from locally saved file in my drive.
curl --location --request POST 'http://localhost:8080/test' \
--header 'Content-Type: application/json' \
--data-raw '{
"fileFormat":"csv",
"version":"v1",
"payload":"<local file content should come here>",
}
Put your data payload into the file and try with this: curl --location --request POST 'http://localhost:8080/test' \ --header 'Content-Type: application/json' \ --d #/path/to/filename.json. Hope this will solve your problem

Resources