I'm trying to use fcm (firebase cloud messaging) to create web push notification, so I started by creating my project on firebase than I got the API key that I added to the HTTP header request, I used wsClient offered by play to send POST HTTP request to the firebase endpoints, But I got the error 401, I tried to use server key, legacy key but it is always the same result.
def sendNotification()={
var url = "https://fcm.googleapis.com/fcm/send"
val request: WSRequest = ws.url(url)
.withHttpHeaders("Authorization"->s" $myserverKey","Content-Type" ->"application/json")
val data = Json.obj()
val futureResponse = request.post(data)
Await.result(futureResponse, Duration.Inf)
Logger.warn(s"send notification to firebase $futureResponse")
error message:
401: The request was missing an Authentication Key (FCM Token). Please,
refer to section "Authentication" of the FCM documentation, at
https://firebase.google.com/docs/cloud-messaging/server.