// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(); FileStream serviceAccount = new FileStream(@"firebaseconfig.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.Configure <MongoAppSettings>(Configuration.GetSection(nameof(MongoAppSettings))); services.AddSingleton <IMongoAppSettings>(sp => sp.GetRequiredService <IOptions <MongoAppSettings> >().Value); services.AddScoped <MongoContext>(); services.AddScoped <JobDetailRepository>(); services.AddScoped <AssignmentsRepository>(); services.AddScoped <UserRepository>(); services.AddScoped <UserDetailsRepo>(); services.AddScoped <AuthenticationApi>(); services.AddScoped <FireBaseRepo>(); services.AddScoped <PlaceApi>(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); services.AddSwaggerDocument(); }
public static FirebaseAdmin.Auth.FirebaseAuth GetFirebaseAdminAuth(Stream input) { FirebaseAdmin.Auth.FirebaseAuth auth; FirebaseAdmin.AppOptions options = new FirebaseAdmin.AppOptions() { Credential = GoogleCredential.FromStream(input), ProjectId = "gbvresponse-609d1", ServiceAccountId = "*****@*****.**", }; if (FirebaseAdmin.FirebaseApp.DefaultInstance == null) { var app = FirebaseAdmin.FirebaseApp.Create(options); auth = FirebaseAdmin.Auth.FirebaseAuth.GetAuth(app); } else { auth = FirebaseAdmin.Auth.FirebaseAuth.DefaultInstance; } return(auth); }
public static FirebaseMessaging GetFirebaseMessaging(Stream input) { FirebaseMessaging messaging; FirebaseAdmin.AppOptions options = new FirebaseAdmin.AppOptions() { Credential = GoogleCredential.FromStream(input), ProjectId = "gbvresponse-609d1", ServiceAccountId = "*****@*****.**", }; if (FirebaseAdmin.FirebaseApp.DefaultInstance == null) { var app = FirebaseAdmin.FirebaseApp.Create(options); messaging = FirebaseMessaging.GetMessaging(app); } else { messaging = FirebaseMessaging.DefaultInstance;//.FirebaseAuth.DefaultInstance; } return(messaging); }