B4J Question firebase messages running on raspberry

MbedAndroid

Well-Known Member
Licensed User
Longtime User
I took the example code for server side (b4j) and integrated in my homemanagement. Running the b4j code on the laptop it works: i can send a notification to the app on my phone. But the same code running on the rasberry gives this message from google:
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CREDENTIALS_MISSING",
"domain": "googleapis.com",
"metadata": {
"method": "google.firebase.fcm.v1.FcmService.SendMessage",
"service": "fcm.googleapis.com"
}
}
]
}
}
So next i filled the requested Credentials and got a ClientID for a device. But where should i store this in the example code? The projectID and the API key are there (and working as the program runs on my laptop). But how to proceed to get this working server side running on a raspberry Pi?
Someone solved this problem?
 

derez

Expert
Licensed User
Longtime User
Check if you have put the json file in the correct folder, where the application jar file is:
B4X:
    Private ServiceAccountFilePath As String = "/home/pi/tempjars/xxxxx.json"
 
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
Are you running the B4J program on the RPi?

The exact same code should work.
result running on PC, same code:

{
"message": {
"data": {
"title": "TEST!",
"body": "testknop aangeklikt"
},
"android": {
"priority": "high"
},
"topic": "general"
}

resultaat van firebase:{
"name": "projects/domotica-b8569/messages/7142496539144587259"
}
running code on Rpi (Zero)
{
"message": {
"data": {
"title": "TEST!",
"body": "testknop aangeklikt"
},
"android": {
"priority": "high"
},
"topic": "general"
}
}

{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CREDENTIALS_MISSING",
"domain": "googleapis.com",
"metadata": {
"method": "google.firebase.fcm.v1.FcmService.SendMessage",
"service": "fcm.googleapis.com"
}
}
]
}
}
Note: running non-ui on the PC, in debug mode. Make that the difference?
 
Upvote 0
Top