I send voip notifications using curl to apns server. I use the following script:
curl -v \
--header "apns-topic: **.voip" \
--header "apns-priority: 10" \
--header "apns-push-type: voip" \
--header "apns-expiration: 0" \
--cert-type P12 --cert *** \
--data '{}' \
--http2 \
https://${APNS_HOST_NAME}/3/device/${DEVICE_TOKEN}
I disable wifi and cellular data for 1 min and send voip notication.
apns-expiration header works fine when APNS_HOST_NAME is api.sandbox.push.apple.com - I don't receive voip notification.
But when APNS_HOST_NAME is api.push.apple.com - I receive voip notification when I enable wifi back after 1 min, 1.5 min ...
I'm not sure what is wrong and what causes such difference in sandbox and production modes. Does anyone know how to solve this?
Try removing the aps json block from the data payload
"aps": {
"alert": ""
}
Related
We are trying to migrate the TOTP factor from Authy to Verify API in Twilio. We reference the following article for the same
https://www.twilio.com/docs/authy/export-totp-secret-seed-for-migrating-to-verify-totp#export-totp-secret-seed-of-a-user
From above URL, we were able to pinpoint how to extract the secret created in the Authy. But, we are unsure as to how a secret extracted from the Authy can be used to create a factor in the Verify API. Can you please tell us in detail how to achieve the same?
Since I don't know what programming language you're using, I'll use cURL commands and you can translate those HTTP requests into your language of choice.
First, you'll need to ask Twilio support to enable the migration tools for your Authy app. They will ask you for Authy app ID which you can find in the URL of the Twilio Console when you navigate to your Authy app.
Then you can use the export TOTP secret API that you linked earlier:
curl -i "https://api.authy.com/protected/json/users/$AUTHY_USER_ID/secret/export" \
-H "X-Authy-API-Key: $AUTHY_API_KEY"
$AUTHY_USER_ID is the individual Authy User ID for which you are
trying to move their TOTP factor to the Verify service.
$AUTHY_API_KEY is the API key for your Authy App.
The output will look like this:
{"secret":"[REDACTED]","otp":"[REDACTED]","success":true}
The secret is what you need to create a Factor in the Verify service
The otp is the one time passcode, the same as what the user would see in their TOTP consumer app (Authy/Google Authenticator/etc).
Now you can use the Verify API to create a new Factor:
curl -X POST "https://verify.twilio.com/v2/Services/$VERIFY_SERVICE_SID/Entities/$IDENTITY/Factors" \
--data-urlencode "Binding.Secret=$EXPORTED_AUTHY_SECRET" \
--data-urlencode "Config.Alg=sha1" \
--data-urlencode "Config.TimeStep=30" \
--data-urlencode "Config.CodeLength=6" \
--data-urlencode "Config.Skew=1" \
--data-urlencode "FriendlyName=John's Phone" \
--data-urlencode "FactorType=totp" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
$VERIFY_SERVICE_SID is the SID of your Verify Service.
$IDENTITY is a unique ID for your user, length between 8 and 64 characters, generated by your external system, such as your user's UUID, GUID, or SID. If the identity does not exist yet, it'll be created automatically as part of this API call.
$EXPORTED_AUTHY_SECRET is the secret that was returned by the Authy Export API earlier.
$TWILIO_ACCOUNT_SID is your Twilio Account SID.
$TWILIO_AUTH_TOKEN is your Twilio Auth Token.
This API call is documented here: https://www.twilio.com/docs/verify/quickstarts/totp#create-a-new-totp-factor
You can use the otp returned by the Authy Export API to verify the new Factor you created:
curl -X POST "https://verify.twilio.com/v2/Services/$VERIFY_SERVICE_SID/Entities/$IDENTITY/Factors/$FACTOR_SID" \
--data-urlencode "AuthPayload=$OTP_CODE" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
$FACTOR_SID is the SID of your newly created Factor.
$OTP_CODE is the otp code returned by the Authy Export API.
This API call is documented here: https://www.twilio.com/docs/verify/quickstarts/totp#verify-that-the-user-has-successfully-registered
That's it! If you want to verify your user's OTP code, you can create a challenge like this:
curl -X POST "https://verify.twilio.com/v2/Services/$VERIFY_SERVICE_SID/Entities/$IDENTITY/Challenges" \
--data-urlencode "AuthPayload=$OTP_CODE" \
--data-urlencode "FactorSid=$FACTOR_SID" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
$OTP_CODE is the otp code given to your application by your user.
This API call is documented here: https://www.twilio.com/docs/verify/quickstarts/totp#validate-a-token
When exporting from Authy API and creating new factors in Verify, you need to do this quickly so you can verify the new factor using the OTP code given from the Authy export. Here's how I did it for a single Authy user using a bash script:
#!/bin/bash
EXPORTED_RESPONSE=$(
curl -s "https://api.authy.com/protected/json/users/$AUTHY_USER_ID/secret/export" \
-H "X-Authy-API-Key: $AUTHY_API_KEY"
)
echo "$EXPORTED_RESPONSE"
EXPORTED_AUTHY_SECRET=$(echo -n "$EXPORTED_RESPONSE" | jq -r .secret)
OTP_CODE=$(echo -n "$EXPORTED_RESPONSE" | jq -r .otp)
IDENTITY=$(uuidgen)
NEW_FACTOR_RESPONSE=$(curl -s -X POST "https://verify.twilio.com/v2/Services/$VERIFY_SERVICE_SID/Entities/$IDENTITY/Factors" \
--data-urlencode "Binding.Secret=$EXPORTED_AUTHY_SECRET" \
--data-urlencode "Config.Alg=sha1" \
--data-urlencode "Config.TimeStep=30" \
--data-urlencode "Config.CodeLength=6" \
--data-urlencode "Config.Skew=1" \
--data-urlencode "FriendlyName=John's Phone" \
--data-urlencode "FactorType=totp" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN)
echo "$NEW_FACTOR_RESPONSE"
FACTOR_SID=$(echo -n "$NEW_FACTOR_RESPONSE" | jq -r .sid)
VERIFY_FACTOR_RESPONSE=$(curl -s -X POST "https://verify.twilio.com/v2/Services/$VERIFY_SERVICE_SID/Entities/$IDENTITY/Factors/$FACTOR_SID" \
--data-urlencode "AuthPayload=$OTP_CODE" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN)
echo "$VERIFY_FACTOR_RESPONSE"
The various environment variables that were described earlier should be set prior to executing this.
I have in my Flutter project APIs that use cookies and they don't work. I have enabled the interceptor that generates the curl:
CurlLoggerDioInterceptor (printOnSuccess: true)
with the following result:
curl -i \
-H "Accept: application / json" \
-H "Connection: keep-alive" \
-H "cookie: ci_session = uv0hts7fb8us0r7m5vvaa64p4o89u9he" \
-H "Authorization: 1652292531" \
"http://xxxxx.it"
And this works on shell. I don't understand, why the curl generated by Dart code works and the code itself doesn't work?
Regarding the code I've used all the solutions in this link (dio_cookie_manager, NetworkService, HTTP request instead of dio...) How do I make an http request using cookies on flutter?
With Dio is not possible, but with the following library yes:
flutter_curl: ^0.1.1
Why is iOS not delivering push notifications to my device?
I am sending a push notification using curl, like so:
curl -v \
--http2 \
--header "apns-push-type: alert" \
--header "apns-priority: 10" \
--header "authorization: bearer $jwt" \
--header "apns-topic: ${BUNDLEID}" \
--data '{"aps": {"content-available": 1, "interruption-level": "active"}, "alert": {"title":"title", "body": "body"}}' \
"${URL}"
Unfortunately, when I look in Console.app, I see the log:
[uk.orth.pushExampleTemporary] Received remote notification request FDCA-F040 [ waking: 0, hasAlertContent: 0, hasSound: 0 hasBadge: 0 hasContentAvailable: 1 hasMutableContent: 0 pushType: Alert]
[uk.orth.pushExampleTemporary] NOT requesting DUET deliver content-available, non-notifiying push notification FDCA-F040 [pushType: Alert willNotifyUser: 0]
[uk.orth.pushExampleTemporary] NOT delivering non-notifying push notification FDCA-F040 [pushType: Alert willNotifyUser: 0]
JSON structure problem
I've noticed that I set the data payload to be something slightly wrong 😢, which was caused by formatting my payload in bash instead of a type in programming language.
The line containing the payload (--data) should look like:
--data '{"aps": {"content-available": 1, "alert": {"title":"title", "body": "body"}}}' \
Avoiding this problem in the future
I've moved over to using a json file (ios_alert_message.json) to avoid these types of errors, using the curl command:
curl -v \
--http2 \
--header "apns-push-type: alert" \
--header "apns-priority: 10" \
--header "authorization: bearer $jwt" \
--header "apns-topic: ${BUNDLEID}" \
--header "Content-Type: application/json" \
--data #"$CURRENT_DIR/ios_alert_message.json" \
"${URL}"
Can anyone please help me out. I'm getting error while generating KONG client credentials on HTTP port 8000.
{
"error_description": "You must use HTTPS",
"error": "access_denied"
}
I have added trusted_ips = 0.0.0.0/0,::/0 in kong.conf also, but it didn't work.
You should do it over https(using port 8443 instead of 8000).If youre using localhost Do something like:
curl -X POST \
--url "https://127.0.0.1:8443/<route name>/oauth2/token " \
--header "Host: <route host>" \
--data "grant_type=password" \
--data "client_id=<clientid>" \
--data "client_secret=<clientsecret>" \
--data "provision_key=<provision_key>"\
--data "redirect_uri=http://localhost/cb/" \
--data "authenticated_userid=<userid>" \
--insecure
you can follow this link for further details on how to go about this
I try to implement firebase in my iOS app.
I can't get pushes on my device.
For debug I tried to use curl request:
curl --header "Content-Type: application/json" \
--header "Authorization: key=<my key here>" \
https://fcm.googleapis.com/fcm/send \
-d '{"notification": {"body": "Hello from curl via FCM!", "sound": "default"},
"priority": "high",
"to": "<my token here>"}'
If I try to use token that I get, launching app on real device I got following: error:"InvalidRegistration"
If I use token from my Android colleague (or even token I got from launch app on simulator device) I succeed and got something like message id in response.
How to fix that?
Your payload seems to be incorrect, try following command in terminal and adjust it as per your requirement:
curl -X POST -H "Authorization: key=<my key here>" -H "Content-Type: application/json" -d '{
" data ": {
"title": "Notification title",
" body ": {
"name": "Body text",
}
},
"to": "<my token here>"
}' "https://fcm.googleapis.com/fcm/send"