public void CreateClients() { UserCRUDClient = new UserCRUD.UserCRUDClient(channel); AccountCRUDClient = new AccountCRUD.AccountCRUDClient(channel); AuthenticationClient = new Authentication.AuthenticationClient(channel); SessionCRUDClient = new SessionCRUD.SessionCRUDClient(channel); CreationClient = new Creation.CreationClient(channel); TransactionCRUDClient = new TransactionCRUD.TransactionCRUDClient(channel); }
public static string getAuthToken() { Authentication.AuthenticationClient authClient = new Authentication.AuthenticationClient(); try { string authToken = authClient.AuthenticateUser("Admin","livelink"); return authToken; } catch (Exception e) { Console.Write("Exception while proceeding authentication."); } finally { authClient.Close(); } return null; }
public static string getAuthToken() { Authentication.AuthenticationClient authClient = new Authentication.AuthenticationClient(); try { string authToken = authClient.AuthenticateUser("Admin", "livelink"); return(authToken); } catch (Exception e) { Console.Write("Exception while proceeding authentication."); } finally { authClient.Close(); } return(null); }
static async Task Main(string[] args) { // Include port of the gRPC server as an application argument var port = args.Length > 0 ? args[0] : "50051"; var channel = new Channel("localhost:" + port, ChannelCredentials.Insecure); var client = new Authentication.AuthenticationClient(channel); var reply = await client.AuthenticateAsync(new User() { Username = "******", Password = "******", RememberMe = true }); Console.WriteLine("Response: " + reply.Status); await channel.ShutdownAsync(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
static async Task Main(string[] args) { var service = "authentication"; switch (service) { case "authentication": { var credentials = new LoginRequest { Username = "******", Password = "******" }; var channel = GrpcChannel.ForAddress("https://localhost:5001"); var client = new Authentication.AuthenticationClient(channel); var authorization = client.Login(credentials); var jwt = authorization.AccessToken == null ? "null" : authorization.AccessToken; Console.WriteLine($"JWT: {jwt}"); credentials = new LoginRequest { Username = "******", Password = "******" }; authorization = client.Login(credentials); jwt = authorization.AccessToken == null ? "null" : authorization.AccessToken; Console.WriteLine($"JWT: {jwt}"); break; } case "greeter": { var input = new HelloRequest { Name = "Jim Bob" }; var channel = GrpcChannel.ForAddress("https://localhost:5001"); var client = new Greeter.GreeterClient(channel); var reply = await client.SayHelloAsync(input); Console.WriteLine(reply.Message); break; } case "meter": { var channel = GrpcChannel.ForAddress("https://localhost:5001"); var meterClient = new RemoteMeter.RemoteMeterClient(channel); var meterInput = new MeterLookupModel { MeterId = 3 }; var meterReply = await meterClient.GetMeterInfoAsync(meterInput); Console.WriteLine($"{meterReply.MeterNumber}"); break; } } Console.ReadLine(); }