Firebase API - Authentication Token

So primarily just noting this for anyone else because it was driving me nucking futs, but I do have one suggestion for Lucee as well.
I’ve been trying to work with Google’s Firebase API but have been struggling just getting past basic authentication. The endpoint I was trying to use was:[API_KEY]
as noted in there documentation here.

Whenever I tried it though I kept getting a 404 error, which returned html, rather than any sort of json error like you normally see with an API.
(in hindsight this should have told me where the error was right away, but I also found some comments on stackoverflow suggesting this was no longer the correct endpoint so eh)

Further confusing me was that the request worked when I used postman on my local machine.
My assumption at this point was that either
a) Google was blocking our servers hosted on Azure
b) There was some extra headers being added by either Lucee or postman, or they were using different character encodings or something

After several hours of pulling my hair out, it finally clicked when I went back and looked at the original error message. The path was showing as this.
Lucee was doing it’s job correctly, and escaping the characters
Just setting encodeurl=false fixed it :weary:

So I do have one suggestion that I think would be a huge help for situations like this. One thing that I was trying to do was get a look at the actual HTTP request that was being generated to try and figure out what was actually being sent, and if I was missing something or there was something else being included, etc.
I was actually using to catch the request so I could view them, but due to me thinking there wasn’t a problem with the url, I didn’t include the full path (so that was my bad).
But even if I had done this it could have still proved problematic. Since these also contained sensitive authentication info, I was having to truncate the values to avoid security issues, so there still could have been some underlying bug I couldn’t see.

So it would have been really great if the http request generated by lucee could be saved as a string or a file, instead of being sent out. Simplest option would just be to include a flag called ‘debug’ or something like it, and if it’s set, the result variable is just replaced with the string that is the http request.

One thing that I have been asking is to get a struct from what is actually being sent out on a cfhttp request. So you can send out the request but it shows you all the headers, body, params , form etc

there are many libraries that make very dynamic HTTP calls and debugging them can be a nightmare. (hey, I even wrote some!) so have something like <cfhttp requestData="myrequestdata"...> so that we can dump it and just eyeball what we are sending it would be great.

That would be nice to have

If I need to debug thinks like that or like this here I create a template with simple dump(gethttprequestdata()) on a dev URL endpoint. Then I can direct the cfhttp to that URL to view that data, and also, compare the data with the request data of other tools (e.g. postman).

1 Like