Ionic push: Authorization header is missing


#1

Hello!

I have a ionic1 app running well on iOS and Android with push notifications (using ionic platform alpha).
Now I’m trying to migrate it to ionic platform beta but I can’t manage to make it work…

I’ve setup a security profile and uploaded the iOS certificate and the Android GCM key. I’ve also created an API token.

If I run an authentication test everything works as expected:
curl -H "Authorization: Bearer API_TOKEN" https://api.ionic.io/auth/test

{“meta”: {“status”: 200, “version”: “2.0.0-beta.0”, “request_id”: “a4a73f88-0fc5-4eb1-8eec-908b7eac24a6”}, “data”: {“success”: “You have successfully made an authenticated request to the Ionic Platform API”}}

When I try to send a notification using the same API TOKEN, the API return “enqueued”:
curl -X POST -H "Authorization: Bearer API_TOKEN" -H "Content-Type: application/json" -d '{ "tokens": ["DEVICE_TOKEN"], "profile": "production","notification": {"message": "Hello World!"}}' https://api.ionic.io/push/notifications

{…“state”: “enqueued”, “status”: “open”}

Then, if I check the notification status using its UUID, I get “Authorization header is missing.”, but i’ve used the same header in the first test…
https://api.ionic.io/push/notifications/UUID/messages

{“error”: {“link”: null, “message”: “Authorization header is missing.”, “type”: “Unauthorized”}, “meta”: {“request_id”: “9ff94919-d29a-4e6c-89bb-900919d35a14”, “status”: 401, “version”: “2.0.0-beta.0”}}

Any idea what’s happening?

Thank you very much!


#2

Did you have any luck solving this oscarmari? I’m running into the exact same issue.


#3

Hi @wadenovak!

It’s a bit dumb in my case…

I was trying to check the status of the notification directly in the browser, accessing to the URL https://api.ionic.io/push/notifications/UUID/messages
I had to do it through a curl query: curl -H “Authorization: Bearer API_TOKEN” https://api.ionic.io/push/notifications/UUID/messages


#4

Ah I see! Thanks for getting back to me @oscarmari

My mistake was dumb as well. I wasn’t sending the Authorization: Bearer XXXXX token with the get request through curl so it was getting denied. It wasn’t the actual push notification that was triggering the “Authorization header is missing” error it was my request to the API.

Hopefully our mistakes help someone else down the line!


#5

i am getting the same error wadenovak can u plz explain hw u get this thing done!