【问题标题】:retrieve data from firebase real time database using firesharp library in c#使用 c# 中的 firesharp 库从 firebase 实时数据库中检索数据
【发布时间】:2018-04-19 10:06:35
【问题描述】:
IFirebaseConfig config = new FirebaseConfig();
config.Serializer = new ServiceStackJsonSerializer(); //Register ServiceStack.Text
config.Serializer = new JsonNetSerializer();          //Register Json.Net
config.AuthSecret = "authsecret here";
config.BasePath = "https://xyz.firebaseio.com/";
IFirebaseClient client = new FirebaseClient(config);
FirebaseResponse response = client.Get("abc/pqr");
Context.Response.Flush();
Context.Response.Write(response.ToString());

我收到错误响应,因为“无法解析身份验证令牌”,我正在使用 FireSharp 库并尝试从 firebase 数据库中检索数据

【问题讨论】:

    标签: c# asp.net firebase firebase-realtime-database fire-sharp


    【解决方案1】:

    我看到您没有在 firebaseconfig 中定义身份验证密钥。请参阅 github project

    IFirebaseConfig config = new FirebaseConfig
    {
         AuthSecret = "your-auth-secret",
         BasePath = "<your-firebase-reference-link>.firebaseio.com/"
    
    };
    
    IFirebaseClient client;
    
    client = new FirebaseClient(config);
             await client.OnAsync("FireSharp/Name/", (sender, args) =>
             {
                    //Gets the Unique ID and deletes the any other string attached to it
                    string dataFromFB = args.Data;
                    string paths = args.Path;
                    string key = RemoveNameSubstring(paths);
                    string uniqueKey = key.Split('/').Last();
                    if (keyHolder.ContainsKey(uniqueKey))
                    {
                        keyHolder[uniqueKey] = dataFromFB;
                        AddToListView(dataFromFB);
                    }
                    else
                    {
                        keyHolder.Add(uniqueKey, dataFromFB);
                        AddToListView(dataFromFB);
                    }
             });
    

    【讨论】:

    • 能够通过输入正确的身份验证密码来解决上述问题,您可以在您的firebase帐户中找到它=>设置=>服务帐户=>数据库密码
    猜你喜欢
    • 1970-01-01
    • 2019-04-16
    • 2020-12-09
    • 2021-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-11
    • 2019-02-04
    相关资源
    最近更新 更多