【问题标题】:C#: How to get Firebase user jwt token without incoming request?C#:如何在没有传入请求的情况下获取 Firebase 用户 jwt 令牌?
【发布时间】:2019-08-15 12:35:20
【问题描述】:

我想写集成测试,所以我需要附加 Firebase jwt 令牌来调用 api 方法。 我没有任何传入请求,我想通过调用一些 Firebase api 方法或使用一些 Firebase C# 库来获取令牌。目前,我没有找到任何合适的库,有一些现有的但它们已经过时了。

【问题讨论】:

    标签: firebase asp.net-core firebase-authentication jwt bearer-token


    【解决方案1】:

    好的,答案很简单。 谷歌向connect with email/password.提供api https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=[API_KEY]

    所以,这些都工作得很好。

    HttpResponseMessage response;
    response = await client.PostAsync(FirebaseSignInUri, content);
    if (!response.IsSuccessStatusCode)
    {
       response = await client.PostAsync(FirebaseSignUpUri, content);
    }
    response.EnsureSuccessStatusCode();
    
    string responseBody = await response.Content.ReadAsStringAsync();
    var authResponse = JsonConvert.DeserializeObject<AuthorizationResponse>(responseBody);
    return authResponse;
    

    【讨论】:

      猜你喜欢
      • 2018-05-21
      • 2020-09-06
      • 2021-10-28
      • 1970-01-01
      • 2019-09-23
      • 2015-10-02
      • 2017-09-20
      • 2018-03-01
      • 2018-07-20
      相关资源
      最近更新 更多