'How to get data from Firebase using c# and using JSON key but not using GOOGLE_APPLICATION_CREDENTIALS
I am using Google.Cloud library for c#, and I want to get data from my Firestore database. I want to use JSON key, but I dont want to put it to GOOGLE_APPLICATION_CREDENTIALS variable.
my json Key is stored in C# variable
string jsonKey = ...;
project id is stored in other variable:
string projectId = ...;
How to do it.
Solution 1:[1]
If you've got the full service account credential JSON in jsonKey, then you just need:
var firestoreDb = new FirestoreDbBuilder
{
ProjectId = projectId,
JsonCredentials = jsonKey
}.Build();
Basically each "client" type (in this case FirestoreDb) provides a corresponding builder class which is intended to make it easy to provide everything you need. (In the next major version, to be released fairly soon, this will also provide integration with Microsoft.Extensions.DependencyInjection.)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jon Skeet |
