PushNotification icon indicating copy to clipboard operation
PushNotification copied to clipboard

401 Unauthorized, Request is missing required authentication credential. Expected OAuth 2

Open kinocalde opened this issue 6 years ago • 2 comments

PushNotification::setService('fcm') ->setMessage([ 'notification' => [ 'title'=>'title', 'body'=>'hello w', 'sound' => 'default' ] ]) ->setDevicesToken($devices) ->send() ->getFeedback();

Error: {"success":false,"error":"Client error: POST https:\/\/fcm.googleapis.com\/v1\/projects\/************\/messages:send resulted in a 401 Unauthorized response:\n{\n "error": {\n "code": 401,\n "message": "Request is missing required authentication credential. Expected OAuth 2 (truncated...)\n"}

According to firebase "All HTTP requests to API v1 must be authorized with an access token OAuth 2.0" and to obtain said token I must generate a file of private keys in JSON format and use that key to recover said access token of OAuth 2.0 of short duration. I already have the JSON file obtained in my firebase, but I must now have said OAuth 2.0 access token and I do not know if I can do this in any way in this package ... Any idea?

kinocalde avatar Feb 09 '19 21:02 kinocalde

Hi @kinocalde ,

Have you set the apiKey for fcm in the config file?

Edujugon avatar Feb 10 '19 15:02 Edujugon

Yes

kinocalde avatar Feb 13 '19 13:02 kinocalde