Exemplo n.º 1
0
        public void TestAuthenticateDummyUser()
        {
            AuthClient client = new AuthClient(Configuration);

            AuthDto.AuthUser authUser = new AuthDto.AuthUser
            {
                Username = "******",
                Password = "******"
            };
            AuthDto.AuthToken authToken = client.AuthenticateUser(authUser).GetAwaiter().GetResult();
            Assert.IsNotNull(authToken);
            Assert.IsNotNull(authToken.Token);
        }
Exemplo n.º 2
0
        public HttpResponseMessage Login(LoginInformations loginInformations)
        {
            var authResult = apiClient.AuthenticateUser(
                loginInformations.Username,
                loginInformations.Password);

            var message = new HttpResponseMessage(authResult.StatusCode);

            if (authResult.StatusCode != HttpStatusCode.OK)
            {
                message.Content = new StringContent(authResult.ErrorMessage);
                return(message);
            }
            return(Request.CreateResponse(HttpStatusCode.OK,
                                          new Credentials
            {
                UserId = authResult.UserId,
                AccessToken = apiClient.AccessToken
            },
                                          Configuration.Formatters.JsonFormatter));
        }