static void Main() { FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile(Path.Combine(Environment.CurrentDirectory, @"UsDA1QA.dll")) }); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new LogIn()); }
//translate all records private void Button3_Click(object sender, EventArgs e) { if (!isInTranslationProcess) { isInTranslationProcess = true; btnTranslateAll.Text = "Stop Translating"; } else if (isInTranslationProcess) { btnTranslateAll.Text = "Re-Translate All"; isInTranslationProcess = false; if (worker.IsAlive) { worker.Abort(); } } worker = new Thread(new ThreadStart(new Action(() => { var creds = GoogleCredential.FromFile("cred\\cred.json"); TranslationClient client = TranslationClient.Create(creds); foreach (DataGridViewRow row in dataGridView1.Rows) { try { if (row.Cells[0].Value.ToString() != "") { if (!isInTranslationProcess && worker.IsAlive) { worker.Abort(); } var result = client.TranslateText("מיכאל " + row.Cells[0].Value.ToString(), "en", "he", TranslationModel.NeuralMachineTranslation); var word = result.TranslatedText.Substring(7).Trim(); if (word != row.Cells[1].Value.ToString().Trim()) { logger.Info($"Hebrew Name {row.Cells[0].Value.ToString()}:Changed From : {row.Cells[1].Value.ToString()} to : {word}"); row.Cells[1].Value = word; row.DefaultCellStyle.BackColor = Color.Yellow; } } } catch (Exception ex) { logger.Debug($"Inside worker function , {ex.Message}"); client.Dispose(); } } }))); worker.Start(); }
public static object AuthExplicit(string projectId) { var credential = GoogleCredential.FromFile(@"C:\Users\Pkuma\Documents\Personal\Trevista\vserve-fc2042b5ca27.json"); var storage = StorageClient.Create(credential); var buckets = storage.ListBuckets(projectId); foreach (var bucket in buckets) { Console.WriteLine(bucket.Name); } return(null); }
public async Task <Google.Apis.Storage.v1.Data.Object> SaveFileToGoogleCloud(string filePath, string name) { var credential = GoogleCredential.FromFile(this.keypath); var storage = StorageClient.Create(credential); using (var stream = File.OpenRead(filePath)) { var response = await storage.UploadObjectAsync(this.bucketName, name, null, stream); return(response); } }
/// <summary> /// firebaseTest authenticates the database to connect to Google API /// </summary> public firebaseTest() { //from work desktop => @"C:\Users\rjvarona\Documents\GitHub\Laboratory.MVC\LaboratoryOperatorV1.0\Laboratory-836fc4d08141.json" //from home desktop => @"C:\Users\rjvar\Documents\GitHub\Laboratory.MVC\LaboratoryOperatorV1.0\Laboratory-836fc4d08141.json" GoogleCredential credential = GoogleCredential .FromFile(@"C:\Users\rjvar\Documents\GitHub\Laboratory.MVC\LaboratoryOperatorV1.0\Laboratory-836fc4d08141.json"); ChannelCredentials channelCredentials = credential.ToChannelCredentials(); Channel channel = new Channel(FirestoreClient.DefaultEndpoint.ToString(), channelCredentials); FirestoreClient firestoreClient = FirestoreClient.Create(channel); db = FirestoreDb.Create("laboratory-2letter", client: firestoreClient); }
public GooglePubSubAdapter( AdapterConfiguration adapterConfiguration) { this.credential = GoogleCredential.FromFile($"{Directory.GetCurrentDirectory()}\\{adapterConfiguration.GoogleCredentialFile}") ?? throw new ArgumentNullException(nameof(AdapterConfiguration)); this.adapterConfiguration = adapterConfiguration ?? throw new ArgumentNullException(nameof(AdapterConfiguration)); this.createSettingsPub = new PublisherClient.ClientCreationSettings( credentials: credential.ToChannelCredentials()); this.createSettingsSub = new SubscriberClient.ClientCreationSettings( credentials: credential.ToChannelCredentials()); }
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); }
// [START auth_cloud_explicit] // Other APIs, like Language, accept a channel in their Create() // method. public object AuthExplicit(string projectId, string jsonPath) { var credential = GoogleCredential.FromFile(jsonPath) .CreateScoped(LanguageServiceClient.DefaultScopes); var channel = new Grpc.Core.Channel( LanguageServiceClient.DefaultEndpoint.ToString(), credential.ToChannelCredentials()); var client = LanguageServiceClient.Create(channel); AnalyzeSentiment(client); return(0); }
private void InitializeQueue() { // https://github.com/GoogleCloudPlatform/google-cloud-dotnet/issues/1576 if (_pub == null) { var googleCredential = GoogleCredential.FromFile(_gcpSettings.PubSub.JsonAuthPath).CreateScoped(PublisherServiceApiClient.DefaultScopes); var channel = new Channel(PublisherServiceApiClient.DefaultEndpoint.ToString(), googleCredential.ToChannelCredentials()); _pub = PublisherServiceApiClient.Create(channel); } }
private static StorageClient CreateRequesterPaysClient() { string file = Environment.GetEnvironmentVariable(RequesterPaysCredentialsEnvironmentVariable); if (string.IsNullOrEmpty(file)) { return(null); } var credential = GoogleCredential.FromFile(file); return(StorageClient.Create(credential)); }
public void ServiceAccountCredential() { var options = new AppOptions { Credential = GoogleCredential.FromFile("./resources/service_account.json"), }; var app = FirebaseApp.Create(options); var tokenFactory = FirebaseAuth.DefaultInstance.TokenFactory; Assert.IsType <ServiceAccountSigner>(tokenFactory.Signer); }
public async Task Signer() { var credential = GoogleCredential.FromFile("./resources/service_account.json"); var serviceAccount = (ServiceAccountCredential)credential.UnderlyingCredential; var signer = new ServiceAccountSigner(serviceAccount); Assert.Equal("*****@*****.**", await signer.GetKeyIdAsync()); byte[] data = Encoding.UTF8.GetBytes("Hello world"); byte[] signature = signer.SignDataAsync(data).Result; Assert.True(Verify(data, signature)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var storageConfig = Configuration.GetSection("CloudStorage"); services.AddDataAccessLibrary() .AddSqlDatabase(() => new MySqlConnection(Configuration.GetConnectionString("Default"))) .AddBCryptPasswordHash() .AddGoogleCloudStorage(GoogleCredential.FromFile(storageConfig.GetSection("StorageCredential").Value), options => { options.DownloadStorageBucket = storageConfig.GetSection("DownloadBucket").Value; options.ProfilePictureStorageBucket = storageConfig.GetSection("ProfilePictureBucket").Value; options.AppIconStorageBucket = storageConfig.GetSection("AppIconBucket").Value; }) .AddDefaultTokenProvider(); services.Configure <TheButtonOptions>(options => { options.TimeSpan = TimeSpan.FromHours(15); }); services.AddSingleton(ConfigureMapper()); services.AddTransient <JavaScript>(); services.AddScoped <AlertState>(); services.AddScoped <EditDownloadState>(); services.AddScoped <ProgressTaskState>(); services.AddFileReaderService(); services.AddRazorPages(); services.AddSignalR(); services.AddServerSideBlazor(); services.AddControllersWithViews(); services.AddResponseCompression(options => { options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[] { MediaTypeNames.Application.Octet }); }); var keyRingConfig = Configuration.GetSection("KeyRing"); string keyRingBucket = keyRingConfig.GetSection("BucketName").Value; string dataProtectionObject = keyRingConfig.GetSection("DataProtection").Value; services.AddSharedCookieAuthentication(keyRingBucket, dataProtectionObject); services.AddCustomAuthorization(); }
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 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 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); } }
[InlineData(@"C:\TFS\OnlineServices-d9921f8e5f21.json")]//TODO Students: Put your projectIdHere public void GoogleTranslatorCredentialsTest(string JSONFile) { // If you don't specify credentials when constructing the client, the // client library will look for credentials in the environment. var credential = GoogleCredential.FromFile(JSONFile); using (var client = TranslationClient.Create(credential, TranslationModel.NeuralMachineTranslation)) { var ReturnedValue = client.DetectLanguage("Bonjour Google!").Language; Console.WriteLine(ReturnedValue); Assert.Equal("fr", ReturnedValue); } }
public static ImageAnnotatorClient GetClient() { var path = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, System.AppDomain.CurrentDomain.RelativeSearchPath ?? ""); var credential = GoogleCredential.FromFile($"{path}\\token.json") .CreateScoped(ImageAnnotatorClient.DefaultScopes); var channel = new Grpc.Core.Channel( ImageAnnotatorClient.DefaultEndpoint.ToString(), credential.ToChannelCredentials()); var imageAnnotatorClient = ImageAnnotatorClient.Create(channel); return(imageAnnotatorClient); }
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 }
private ContextsClient CreateDialogflowContextsClient(ScopeContext context) { var credential = GoogleCredential.FromFile(context.Parameters["JsonPath"]).CreateScoped(ContextsClient.DefaultScopes); var clientBuilder = new ContextsClientBuilder { ChannelCredentials = credential.ToChannelCredentials() }; var client = clientBuilder.Build(); return(client); }
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 CreateFirebaseApp(string keyPath) { if (keyPath != _keyPath) { firebaseApp = FirebaseApp.Create(new AppOptions { Credential = GoogleCredential.FromFile(keyPath) }); firebaseAuth = FirebaseAuth.GetAuth(firebaseApp); _keyPath = keyPath; } }
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 }); }
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), }); }
private void SetUp() { Environment.SetEnvironmentVariable( "GOOGLE_APPLICATION_CREDENTIALS", CommonSecurityConstants.PathToFirestoreJson); GoogleCredential.FromFile( CommonSecurityConstants .PathToFirestoreJson); projectId = CommonSecurityConstants.ProjectId; database = FirestoreDb.Create(projectId); }
// 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"), }); }
public GoogleCloudStorage(IConfiguration configuration, IWebHostEnvironment env) { if (env.IsDevelopment()) { var googleCredential = GoogleCredential.FromFile(configuration.GetValue <string>("GoogleCredentialFile")); _storageClient = StorageClient.Create(googleCredential); } else { _storageClient = StorageClient.Create(); } _bucketName = configuration.GetValue <string>("GoogleCloudStorageBucket"); }
public RecordOrderbook(string symbol) { if (symbol == null || symbol.Trim() == "") { throw new MissingFieldException("Please specify a symbol"); } this.symbol = symbol; var credential = GoogleCredential.FromFile("./credentials/bigquery.json"); this.bqClient = BigQueryClient.Create("firebase-lispace", credential); this.socketClient = new BinanceSocketClient(); this.binanceClient = new BinanceClient(); }