// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { //services.AddIdentityCore<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true); // string value = Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS"); //FirebaseApp.Create(new AppOptions() //{ // Credential = GoogleCredential.GetApplicationDefault(), // ServiceAccountId = "*****@*****.**", //}); FileStream serviceAccount = new FileStream(@"vserve-app-firebase-adminsdk-w2m8q-0e8b9f15f9.json", FileMode.Open, FileAccess.Read, FileShare.Read); FirebaseAdmin.AppOptions options = new FirebaseAdmin.AppOptions { Credential = GoogleCredential.FromStream(serviceAccount), ServiceAccountId = "*****@*****.**", }; FirebaseAdmin.FirebaseApp.Create(options); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.Authority = "https://securetoken.google.com/vserve-app"; options.Audience = "https://securetoken.google.com/vserve-app"; options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidIssuer = "https://securetoken.google.com/vserve-app", ValidateAudience = true, ValidAudience = "vserve-app", ValidateLifetime = true }; }); services.AddOptions(); services.AddAuthenticationCore(options => { options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }); services.AddRazorPages(); services.AddServerSideBlazor(); services.AddHttpClient(); services.AddScoped <HttpClient>(); services.AddScoped <AuthenticationStateRepo>(); services.AddScoped <AuthenticationStateProvider>(provider => provider.GetRequiredService <AuthenticationStateRepo>()); services.AddControllers().AddJsonOptions(options => options.JsonSerializerOptions.WriteIndented = true); services.AddSingleton <WeatherForecastService>(); services.AddSingleton <LoginService>(); services.AddSingleton <RegistrationService>(); services.AddScoped <IFireBaseRepo, FireBaseRepo>(); services.AddScoped <DataService>(); services.AddHttpContextAccessor(); }
/// <summary> /// Creates the default app instance with the specified options. /// </summary> /// <returns>The newly created <see cref="FirebaseApp"/> instance.</returns> /// <exception cref="System.ArgumentException">If the default app instance already /// exists.</exception> /// <param name="options">Options to create the app with. Must at least contain the /// <c>Credential</c>.</param> public static FirebaseApp Create(AppOptions options) { return(Create(options, DefaultAppName)); }
internal AppOptions(AppOptions options) { Credential = options.Credential; ProjectId = options.ProjectId; ServiceAccountId = options.ServiceAccountId; }