public void CreateNamedInstance() { const string name = "MyApp"; var app = FirebaseApp.Create(TestOptions, name); Assert.Equal(name, app.Name); Assert.NotNull(app.Options); Assert.Same(app, FirebaseApp.GetInstance(name)); Assert.Throws <ArgumentException>(() => FirebaseApp.Create(TestOptions, name)); app.Delete(); Assert.Null(FirebaseApp.GetInstance(name)); }
public async Task CreateCustomToken() { var cred = GoogleCredential.FromFile("./resources/service_account.json"); FirebaseApp.Create(new AppOptions() { Credential = cred }); var token = await FirebaseAuth.DefaultInstance.CreateCustomTokenAsync("user1"); VerifyCustomToken(token, "user1", null); }
public void GetAuth() { var app = FirebaseApp.Create(new AppOptions() { Credential = MockCredential }, "MyApp"); FirebaseAuth auth = FirebaseAuth.GetAuth(app); Assert.Same(auth, FirebaseAuth.GetAuth(app)); app.Delete(); Assert.Throws <InvalidOperationException>(() => FirebaseAuth.GetAuth(app)); }
public void GetDefaultAuth() { var app = FirebaseApp.Create(new AppOptions() { Credential = MockCredential }); FirebaseAuth auth = FirebaseAuth.DefaultInstance; Assert.Same(auth, FirebaseAuth.DefaultInstance); app.Delete(); Assert.Null(FirebaseAuth.DefaultInstance); }
public async Task <ClienteCarritoDTOs> getCarrito(string uids) { ClienteCarritoDTOs clientecarrito = new ClienteCarritoDTOs(); HttpClient http = new HttpClient(); //Inicializo la app de firebase aca FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile(@"D:\Datos Matias\firebase\Private Key\usuario-5093e-firebase-adminsdk-43fcf-1bf89503c6.json"), }); var result = await FirebaseAuth.DefaultInstance.GetUserAsync(uids); var ExisteCliente = (from x in context.user where x.uid == uids select x.Id).FirstOrDefault <int>(); if (ExisteCliente == 0) { var enityClient = new Usuario() { uid = uids, Nombre = result.DisplayName, gmail = result.Email }; _repository.Add <Usuario>(enityClient); var userrol = new UsuarioRoles() { RoleId = 2, UsuarioId = ExisteCliente }; _repository.Add <UsuarioRoles>(userrol); ExisteCliente = (from x in context.user where x.uid == uids select x.Id).FirstOrDefault <int>(); string url = " https://localhost:44310/api/Carrito/VerificarClienteCarrito?clienteID=" + ExisteCliente; string request = await http.GetStringAsync(url); int gets = JsonConvert.DeserializeObject <int>(request); clientecarrito.CarritoId = gets; clientecarrito.ClienteId = ExisteCliente; clientecarrito.RolId = 2; } else { string url = " https://localhost:44310/api/Carrito/VerificarClienteCarrito?clienteID=" + ExisteCliente; string request = await http.GetStringAsync(url); int gets = JsonConvert.DeserializeObject <int>(request); clientecarrito.CarritoId = gets; clientecarrito.ClienteId = ExisteCliente; clientecarrito.RolId = 2; } return(clientecarrito); }
public static IServiceCollection ResolveDependencies(this IServiceCollection services) { services.AddScoped <AppDbContext>(); var firebaseApp = FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile("./Configuration/GoogleCredentials.json") }); var firebaseAuth = FirebaseAuth.DefaultInstance; services.AddSingleton(firebaseApp); services.AddSingleton(firebaseAuth); services.AddScoped <ICategoryRepository, CategoryRepository>(); services.AddScoped <ICategoryService, CategoryService>(); services.AddScoped <IStateRepository, StateRepository>(); services.AddScoped <IUserRepository, UserRepository>(); services.AddScoped <IUserService, UserService>(); services.AddScoped <ICityHallRepository, CityHallRepository>(); services.AddScoped <ICityHallService, CityHallService>(); services.AddScoped <IReportStatusRepository, ReportStatusRepository>(); services.AddScoped <IReportClassificationRepository, ReportClassificationRepository>(); services.AddScoped <IReportClassificationService, ReportClassificationService>(); services.AddScoped <IUrgencyLevelRepository, UrgencyLevelRepository>(); services.AddScoped <IReportService, ReportService>(); services.AddScoped <IReportRepository, ReportRepository>(); services.AddScoped <IReportCommentaryRepository, ReportCommentaryRepository>(); services.AddScoped <IReportCommentaryService, ReportCommentaryService>(); services.AddScoped <IReportAttachmentRepository, ReportAttachmentRepository>(); services.AddScoped <ICityRepository, CityRepository>(); services.AddScoped <IReportInteractionHistoryRepository, ReportInteractionHistoryRepository>(); services.AddScoped <IReportInteractionHistoryService, ReportInteractionHistoryService>(); services.AddScoped <IRoleRepository, RoleRepository>(); services.AddScoped <IUserRoleRepository, UserRoleRepository>(); services.AddScoped <IUserRoleService, UserRoleService>(); services.AddScoped <IReportInteractionHistoryCommentaryRepository, ReportInteractionHistoryCommentaryRepository>(); services.AddScoped <IReportInteractionHistoryCommentaryService, ReportInteractionHistoryCommentaryService>(); services.AddScoped <IReportInProgressRepository, ReportInProgressRepository>(); services.AddScoped <IReportInProgressService, ReportInProgressService>(); //business logic class services.AddScoped <ReportStatusUpdate, ReportStatusUpdate>(); services.AddScoped <ReportCoordinatorUpdate, ReportCoordinatorUpdate>(); //external services services.AddScoped <IGeolocationService, GeolocationService>(); services.AddScoped <INotifier, Notifier>(); return(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", Configuration.GetSection("GOOGLE_APPLICATION_CREDENTIALS").Value); FirebaseApp.Create(new AppOptions { Credential = GoogleCredential.FromFile(Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS") ?? "GOOGLE_APPLICATION_CREDENTIALS") }); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.Authority = $"https://securetoken.google.com/{Configuration.GetSection("ProjectId").Value}"; options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidIssuer = $"https://securetoken.google.com/{Configuration.GetSection("ProjectId").Value}", ValidateAudience = true, ValidAudience = $"{Configuration.GetSection("ProjectId").Value}", ValidateLifetime = true }; }); services.AddScoped <DatabaseEntities>(); services.AddScoped <WashEventFactory>(); services.AddScoped <ICryptographic, Cryptographic>(); services.AddScoped <IMessageBus, FakeBus>(); services.AddScoped <ITimeService, TimeService>(); services.AddScoped <IEventStore, EventStore>(); services.AddScoped <IUnitOfWork, UnitOfWork>(); services.AddScoped <IUserRepository, UserRepository>(); services.AddScoped <ITransactionRepository, TransactionRepository>(); services.AddScoped <IWashRepository, WashRepository>(); services.AddScoped <ICommandHandler, WashCommandHandler>(); services.AddScoped <ICurrentContext, UserApiContext>(); services.AddScoped <IMapper <UserDbModel, UserDto>, UserMapper>(); services.AddScoped <IMapper <WashDbModel, WashDto>, WashMapper>(); services.AddCors(options => { options.AddPolicy(AllowSpecificOrigins, builder => { builder.WithOrigins("*").AllowAnyHeader().AllowAnyMethod(); }); }); services.AddControllers(); }
public FcmService() { GoogleCredential googleCredential = GoogleCredential.FromFile("./alertportscanner-firebase-adminsdk-80rsu-110f68429b.json"); if (FirebaseApp.DefaultInstance == null) { defaultApp = FirebaseApp.Create(new AppOptions() { Credential = googleCredential }); Console.WriteLine("Create Firebaseapp"); } }
public FirebaseService(IOptions <Configuration.FcmOptions> options) { string path = options.Value.ServiceAccountFilePath; if (!string.IsNullOrWhiteSpace(path)) { FirebaseApp app = FirebaseApp.Create(new AppOptions { Credential = GoogleCredential.FromFile(path) }); messaging = FirebaseMessaging.GetMessaging(app); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(options => { options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; }); services.AddDbContext <MyDbContext>(); services.AddSwaggerGen(); FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile("File/key.json"), }); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); System.Environment.SetEnvironmentVariable(env_variable, configFilePath); FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile(configFilePath), }); }
public AppUserService(string jsonCredentials) { if (FirebaseApp.DefaultInstance == null) { var defaultApp = FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromJson(jsonCredentials), }); } // Retrieve services by passing the defaultApp variable... _firebaseAuth = FirebaseAuth.DefaultInstance; }
internal static void AddPushNotificationService(this IServiceCollection services) { var appFB = FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FireBaseCredentials.json")) }); var msgServiceFB = FirebaseMessaging.GetMessaging(appFB); services.AddScoped <IPushNotificationService>(cfg => new PushNotificationService { messagingFB = msgServiceFB }); }
public FirebaseMessagingWrapper(string projectId, string credentials) { var appOptions = new AppOptions { Credential = GoogleCredential.FromJson(credentials) }; appOptions.ProjectId = projectId; app = FirebaseApp.Create(appOptions, Guid.NewGuid().ToString()); Messaging = FirebaseMessaging.GetMessaging(app); }
public void CreateFirebaseApp(string keyPath) { if (keyPath != _keyPath) { firebaseApp = FirebaseApp.Create(new AppOptions { Credential = GoogleCredential.FromFile(keyPath) }); firebaseAuth = FirebaseAuth.GetAuth(firebaseApp); _keyPath = keyPath; } }
public void ProjectIdFromServiceAccount() { var app = FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile("./resources/service_account.json"), }); var verifier = FirebaseTokenVerifier.CreateIDTokenVerifier(app); Assert.Equal("test-project", verifier.ProjectId); verifier = FirebaseTokenVerifier.CreateSessionCookieVerifier(app); Assert.Equal("test-project", verifier.ProjectId); }
public void GetMessaging() { var app = FirebaseApp.Create(new AppOptions() { Credential = MockCredential }, "MyApp"); FirebaseMessaging messaging = FirebaseMessaging.GetMessaging(app); Assert.NotNull(messaging); Assert.Same(messaging, FirebaseMessaging.GetMessaging(app)); app.Delete(); Assert.Throws <InvalidOperationException>(() => FirebaseMessaging.GetMessaging(app)); }
public void GetDefaultMessaging() { var app = FirebaseApp.Create(new AppOptions() { Credential = MockCredential }); FirebaseMessaging messaging = FirebaseMessaging.DefaultInstance; Assert.NotNull(messaging); Assert.Same(messaging, FirebaseMessaging.DefaultInstance); app.Delete(); Assert.Null(FirebaseMessaging.DefaultInstance); }
private FirebaseMessagingClient() { var path = Directory.GetCurrentDirectory(); var credential = GoogleCredential.FromFile(Directory.GetCurrentDirectory() + "/serviceAccountKey.json").CreateScoped("https://www.googleapis.com/auth/firebase.messaging"); //var credential = GoogleCredential.FromFile("serviceAccountKey.json").CreateScoped("https://www.googleapis.com/auth/firebase.messaging"); var app = FirebaseApp.Create(new AppOptions() { Credential = credential }); firebaseMessaging = FirebaseMessaging.GetMessaging(app); }
public async Task SetCustomUserClaimsNoProjectId() { FirebaseApp.Create(new AppOptions() { Credential = MockCredential }); var customClaims = new Dictionary <string, object>() { { "admin", true }, }; await Assert.ThrowsAsync <ArgumentException>( async() => await FirebaseAuth.DefaultInstance.SetCustomUserClaimsAsync("user1", customClaims)); }
public async Task <IActionResult> GetUserDate() { FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile(@"D:\Datos Matias\firebase\Private Key\usuario-5093e-firebase-adminsdk-43fcf-1bf89503c6.json"), }); var result = await FirebaseAuth.DefaultInstance.GetUserAsync(uid); return(new JsonResult(result) { StatusCode = 201 }); }
public async Task <String> SendNotification(string token, string title, string body) { FirebaseMessaging messaging; var app = FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile(AppDomain.CurrentDomain.BaseDirectory + "/Json/niovarjobsnotifications-firebase-adminsdk.json").CreateScoped("https://www.googleapis.com/auth/firebase.messaging") }); messaging = FirebaseMessaging.GetMessaging(app); return(await messaging.SendAsync(CreateNotification(title, body, token))); //do something with result }
public void NoHttpClientFactory() { var credential = GoogleCredential.FromAccessToken("token"); var options = new AppOptions() { Credential = credential, ProjectId = "test-project", ServiceAccountId = "*****@*****.**", HttpClientFactory = null, }; Assert.Throws <ArgumentNullException>(() => FirebaseApp.Create(options)); }
public void ServiceAccountId() { var options = new AppOptions { Credential = MockCredential, ServiceAccountId = "test-service-account", }; var app = FirebaseApp.Create(options); var tokenFactory = FirebaseAuth.DefaultInstance.TokenFactory; Assert.IsType <FixedAccountIAMSigner>(tokenFactory.Signer); }
public void ApplicationDefaultCredentials() { Environment.SetEnvironmentVariable( "GOOGLE_APPLICATION_CREDENTIALS", "./resources/service_account.json"); try { var app = FirebaseApp.Create(); Assert.NotNull(app.Options.Credential.ToServiceAccountCredential()); } finally { Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", ""); } }
public FirebaseApp Get() { //if (app != null) // return app; var credentials = GoogleCredential.FromFile( hostingEnvironment.ContentRootPath + //@"\Properties\test-fda53dfd531f.json" @"\Properties\active-valve-125910-b1c581ae2447.json"); return(app = FirebaseApp.Create(new AppOptions { Credential = credentials })); }
public void TenantManagerNoProjectId() { FirebaseApp.Create(new AppOptions() { Credential = MockCredential }); var ex = Assert.Throws <ArgumentException>( () => FirebaseAuth.DefaultInstance.TenantManager); Assert.Equal( "Must initialize FirebaseApp with a project ID to manage tenants.", ex.Message); }
static async Task EnviarPush(Message mensagem) { var defaultApp = FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "key.json")), }); Console.WriteLine(defaultApp.Name); // "[DEFAULT]" var messaging = FirebaseMessaging.DefaultInstance; var result = await messaging.SendAsync(mensagem); Console.WriteLine(result); }
public Firebase() { if (File.Exists("Resources/firebase.json")) { FirebaseApp = FirebaseApp.Create(new AppOptions { Credential = GoogleCredential.FromFile("Resources/firebase.json") }); } else { Logger.Log("Firebase configuration not found!", Logger.ErrorLevel.Error); } }
public void ProjectIdFromOptions() { var app = FirebaseApp.Create(new AppOptions() { Credential = MockCredential, ProjectId = "explicit-project-id", }); var verifier = FirebaseTokenVerifier.CreateIDTokenVerifier(app); Assert.Equal("explicit-project-id", verifier.ProjectId); verifier = FirebaseTokenVerifier.CreateSessionCookieVerifier(app); Assert.Equal("explicit-project-id", verifier.ProjectId); }