I have a website that utilizes SQL Server on Azure for all of it's data. I'm partnering with another company to get additional, supplemental information for specific records that exist in my database.
When those "specific reccords" are being viewed, I want to provide another link to retrieve that supplemental information from the Firebase database.
So, I'm trying to write a service that will retrieve this data, here's what I've written so far as a PoC:
private readonly string firebaseUrl = "https://{myproject}.firebaseio.com/";
private readonly string authToken = "x:xxxxxxxxxxx:xxx:xxxxxxxxxxxxxxxx";
public async Task<IEnumerable<InMatchStat>> GetInMatchStats()
{
try
{
var firebase = new FirebaseClient(firebaseUrl, new FirebaseOptions { AuthTokenAsyncFactory = () => Task.FromResult(authToken) });
var stats = await firebase.Child("my/collection/path").OnceAsync<InMatchStat>();
if (stats == null || !stats.Any())
{
return null;
}
return await Convert(stats.AsEnumerable());
}
catch (Exception exception)
{
var message = exception.ToString();
}
return null;
}
This is the error that I'm getting back from Firebase when it tries to execute the var stats = await firebase.Child().... call:
firebase could not parse auth token
Here's a link to the FirebaseDatabase.NET Github page: https://github.com/step-up-labs/firebase-database-dotnet
In case that link goes dead in the future, here's the exact sample that I'm trying to replicate that is shown on that site:
var auth = "ABCDE"; // your app secret
var firebaseClient = new FirebaseClient(
"<URL>",
new FirebaseOptions
{
AuthTokenAsyncFactory = () => Task.FromResult(auth)
});
And the query example from that page:
var firebase = new FirebaseClient("https://dinosaur-facts.firebaseio.com/");
var dinos = await firebase
.Child("dinosaurs")
.OrderByKey()
.StartAt("pterodactyl")
.LimitToFirst(2)
.OnceAsync<Dinosaur>();
foreach (var dino in dinos)
{
Console.WriteLine($"{dino.Key} is {dino.Object.Height}m high.");
}
Where am I going wrong with my implementation?
The Database link and Legacy Secret creation has moved, it is now under "Service Accounts" in Project Settings.found here github.com/dkrprasetya/simple-firebase-unity/issues/…