예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            services.AddSingleton(async mantleConfig =>
            {
                var config = new Configuration
                {
                    BasePath = "https://api.mantle.services"
                };
                var auth         = new AuthenticationApi(config);
                var userResponse = await auth.AuthenticationLoginPostAsync(new UserLoginRequest("mantleEmail", "mantlePass"));
                config.AddDefaultHeader("Authorization", userResponse.AccessToken);
                return(config);
            });

            var corsBuilder = new CorsPolicyBuilder();

            corsBuilder.AllowAnyHeader();
            corsBuilder.AllowAnyMethod();
            corsBuilder.AllowAnyOrigin();
            corsBuilder.AllowCredentials();

            services.AddCors(options =>
            {
                options.AddPolicy("SiteCorsPolicy", corsBuilder.Build());
            });
        }
예제 #2
0
        public async Task Auth(string email, string password)
        {
            Configuration = new Configuration(new ApiClient(URL));

            var auth = new AuthenticationApi(Configuration);

            var tokenres = await auth.AuthenticationLoginPostAsync(new LoginDto(email, password));

            SetToken(tokenres?.Token);
        }
예제 #3
0
        public async Task Auth(string email, string password, string server)
        {
            Console.WriteLine("Dowding Auth");
            Configuration = new Configuration(new ApiClient(String.Format(URL, server)));

            var auth = new AuthenticationApi(Configuration);

            var tokenres = await auth.AuthenticationLoginPostAsync(new LoginDto(email, password));

            SetToken(tokenres?.Token, server);
        }
예제 #4
0
        public async Task Auth(string email, string password, string server)
        {
            // if port 80, change url to non secure
            if (server.EndsWith(":80"))
            {
                URL = "http://{0}/api/1.0";
                WS  = "ws://{0}/ws";
            }

            Console.WriteLine("Dowding Auth");
            Configuration = new Configuration(new ApiClient(String.Format(URL, server)));

            var auth = new AuthenticationApi(Configuration);

            var tokenres = await auth.AuthenticationLoginPostAsync(new LoginDto(email, password));

            SetToken(tokenres?.Token, server);
        }