예제 #1
0
        public async Task<XamarinAuthResponse> GetAuthenticationTokenAsync(XamarinCredentials credentials)
        {
            var content = new Dictionary<string, string>
            {
                { "email", credentials.Email },
                { "password", credentials.Password }
            };

            var response = await client.PostAsync("auth", new FormUrlEncodedContent(content));

            return await response.Content.ReadAsAsync<XamarinAuthResponse>();
        }
예제 #2
0
        public async Task <XamarinAuthResponse> GetAuthenticationTokenAsync(XamarinCredentials credentials)
        {
            var content = new Dictionary <string, string>
            {
                { "email", credentials.Email },
                { "password", credentials.Password }
            };

            var response = await client.PostAsync("auth", new FormUrlEncodedContent(content));

            return(await response.Content.ReadAsAsync <XamarinAuthResponse>());
        }
        private async Task<XamarinAuthResponse> AuthenticateCredentials(XamarinCredentials credentials)
        {
            string authApiKey = ConfigurationManager.AppSettings[XamarinAuthApiKeyName];

            if (authApiKey == null)
            {
                throw new InvalidOperationException("Missing XamarinAuthApiKey configuration setting.");
            }

            using (var authClient = new XamarinAuthClient(authApiKey))
            {
                return await authClient.GetAuthenticationTokenAsync(credentials);
            }
        }