google gcm raw_data (payload encryption) , push event not received - google-cloud-messaging

I need some help because i never receive push event in my serviceworker after payload encryption.
First case without payload encrypted
In this case, I receive push event in service worker:
Request is :
curl -s --header "Authorization: key=MY_KEY" --header "Content-Type: application/json" --header "TTL:86400" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"elmll0-ynBY:APA91bFe7xBGti92H4yrWo2bJT6aMY3IKo3j54yRGtS0NNQYpkqmI5f14EKSPz6_GCEs2PaX6zCD3Lvk-2JRABQVZ3u350bsy0uisxRL0EoZnVHsqVMo7YNojkvQX7o49a61pCmZEfSi\"],\"delay_while_idle\":false,\"collapse_key\":\"hipush-notification\",\"time_to_live\":86400}"
Google response is :
{"multicast_id":5772871775830750210,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1465913797471899%f4d428f3bf364ddd"}]}
Second test, with encrypted raw_data
I never receive push event:
- Request is :
curl -s --header "Authorization: key=MY_KEY" --header "Content-Type: application/json" --header "TTL:86400" --header "Encryption: salt=KYw1fpU-Dg4w1qFcrPY3rQ" --header "Crypto-Key: dh=BOwb4OiwboYRrbhhXh056xFZ8pk8kfQR27Gmu3EdYPG9DkLoKRqA_d4Z_TbT2VYMfHVkGS-dY45rZ8tAimqSWrk" --header "Content-Encoding:aesgcm" https://android.googleapis.com/gcm/send --header "Content-Length: 363" -d "{\"registration_ids\":[\"elmll0-ynBY:APA91bFe7xBGti92H4yrWo2bJT6aMY3IKo3j54yRGtS0NNQYpkqmI5f14EKSPz6_GCEs2PaX6zCD3Lvk-2JRABQVZ3u350bsy0uisxRL0EoZnVHsqVMo7YNojkvQX7o49a61pCmZEfSi\"],\"delay_while_idle\":false,\"collapse_key\":\"hipush-notification\",\"time_to_live\":86400,\"raw_data\":\"rXJHqmhxmTde+297wtb3Tpj5Lq5C8cd2eYW5qTBoC3huGVTOPog6+I2Y6wQEYqP1QIAvUA0NFtYC7Zr\/iCR1sGcu\"}"
Google response is :
{"multicast_id":7840093467258640262,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1465913901129815%f4d428f3bf364ddd"}]}
I got same response with success. My chrome is in version 51.
Can someone explain me where is my error ?
Best regards,
Mehdi

Which language are you using? You could use one of the libraries here https://github.com/web-push-libs (Node.js, PHP, Python, Java currently supported), which have already fixed the problem for you.

Related

Authentication error using cloudflare api

I repeatedly received an authentication error just like this (not me) when using the Cloudflare api.
curl -X GET "https://api.cloudflare.com/client/v4/zones/<ZONEID>/dns_records?type=A&name=<DOMAIN>&content=127.0.0.1&proxied=undefined&page=1&per_page=20&order=type&direction=desc&match=all" \
-H "X-Auth-Email: <EMAIL>" \
-H "X-Auth-Key: <APITOKEN>" \
-H "Content-Type: application/json"
{“success”:false,“errors”:[{“code”:10000,“message”:“Authentication error”}]}
What am I doing wrong?
I was getting that exact same error message, and I found out that I was using the API Token instead of the API Key in the X-Auth-Key parameter.
Apparently the only way that seems to work is to use the user token instead of the zone one.
curl -XPOST -H 'X-Auth-Key: TOKEN' -H 'X-auth-email: EMAIL' -H \"Content-type: application/json\" -d '{\"type\":\"CNAME\",\"name\":\"hi\",\"content\":\"example.com\",\"proxied\":true}' 'https://api.cloudflare.com/client/v4/ZONE_ID/dns_records'

How to import json report through automation using REST API and XRay for JIRA and Cucumber + Xray

I can manually import execution result(report.json) through jira and its giving proper status.But i want to achieve through automation i am unable to do so
How to do so
i tried using below curl command in terminal ..was unable to get expected result
curl -H "Content-Type: application/json" -X POST -u username:password --data #report.json http://myurl.net/rest/raven/1.0/import/execution/cucumber
Note that the curl request you showed is tailored for Xray on Jira server and from the screenshot you're showing, it seems that you're using Xray on Jira Cloud. That requires that you have a token that you need to obtain first of all using another request.
If you're doing it by "hand" (i.e. from the command line), you would need to so something like:
token=$(curl -H "Content-Type: application/json" -X POST --data #"cloud_auth.json" https://xray.cloud.xpand-it.com/api/v2/authenticate| tr -d '"')
curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token" --data #"report.json" https://xray.cloud.xpand-it.com/api/v2/import/execution/cucumber
My cloud_auth.json is something like:
{ "client_id": "215FFD69....","client_secret": "1c00f8f2c..." }
Please check in more detail the authentication API and the endpoint for importing cucumber results (there are two actually) in the cloud.

Get request - formatting JSON file

I want to start a curl request from a batch file. The result is a unformatted data file.
call curl --request GET --url "http:*****" --header "Accept: */*"
--header "Accept-Encoding: gzip, deflate" --header "Authorization:****" --header "Cache-Control: no-cache" --header "Connection: keep-alive" --header "Content-Type: application/json" >****.json
Know anyone a solution to get a format json data file.
Thanks in advance!
May I ask question,
What OS you are using for curl request?
Depending on the OS, there are many ways that you can reformat the json response.
If it is Ubuntu, you can install "json_reformat" library and use in curl command
i.e.
curl ..the url ... | json_reformat

send message mongoose-im not success

I would like to send a message and I call api.
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"caller":"maituanmte%40localhost","to":"admin%40localhost","body": "Hi all"}' 'http://localhost:8088/api/messages'
the status=204 and body response no content. But when I get message by
curl -X GET --header 'Accept: application/json' 'http://localhost:8088/api/messages/admin%40localhost'
then status = 200 and body=[] (no messages). I have exchange admin and maituanmte but the same result.
Please help me. Thanks
Messages will be returned from the server only if mod_mam is enabled. Could you confirm you have this module enabled and configured?
I recommend using MongooseIM from master branch [1] as the MAM configuration was significantly simplified recently [2], [3]
[1]. https://github.com/esl/MongooseIM
[2]. https://github.com/esl/MongooseIM/blob/master/doc/modules/mod_mam.md
[3]. http://mongooseim.readthedocs.io/en/latest/modules/mod_mam/

How to play with the CloudApp API in CURL?

I am trying to play with the CloudApp API with CURL and it keeps giving me the redirect message, and I don't think I'm initializing it right. The docs are at http://support.getcloudapp.com/faqs/developers/api and my request currently looks like:
curl -G --digest -u user#domain.com:[censored] -H "Content-Type: application/json" http://my.cl.ly/items/new
Any ideas?
You may also need to include -H "Accept: application/json"