Cloud Messaging & Authentication

352 views
Skip to first unread message

Jacob W

unread,
Nov 8, 2021, 5:53:18 PM11/8/21
to Firebase Google Group
I'm looking to use Cloud Messaging for notifications, however Firebase doesn't have an SDK for our platform Lucee.  This isn't an issue in and of itself, however the REST API documentation for working with regular HTTP request has proven... problematic.

Using the documentation found here:
I was able to use the service account's public key to mint a JWT token and get an id token and refresh token from the signInWithCustomToken endpoint.  However when I try to use with the messages:send endpoint, I get this message:
401 Unauthenticated:  Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

Side note:  I've found mixed sources online regarding how to use the tokens returned by signInWithCustomToken.  I found some references stating that you can use the idToken it returns as the Bearer token, and others that say you need to use the refreshToken returned alongside the idToken, pass it to securetoken.googleapis.com/v1/token, and then get the new refresh_token and actual access_token, and use the latter as the Bearer token.  I've tried both methods and neither worked for me (clarification: I WAS able to get the new access_token, but got the same error message as mentioned above when I tried to use it).

Following the link mentioned in the error message (which btw wasn't linked anywhere from the firebase documentation as far as I could tell)  I found the following page which discusses minting a JWT token and using that as the actual Bearer token.
However when I tried using that token with the messages:send endpoint, I got a new error saying something along the lines of "this is not a valid FCM registration token", so I'm not sure what to make of that in this context.

I genuinely am not sure what I'm missing in the documentation.  I've also tried downloading a few of the SDK's to see if they could give me a hint of what it is I'm missing, but most of them are in languages I don't use frequently, and the ones that are were clearly written by someone who understood the API very, very well.  I'm sure it makes a lot of sense for them, but not much for me.

Appreciate any help you all can provide




Reply all
Reply to author
Forward
0 new messages