internal static CustomerIdentity GetUserFromEmailAddress(string emailaddress)
        {
            var identity = new CustomerIdentity("Claims");
            identity.AddClaim(new Claim("emailaddress", emailaddress));

            return identity;
        }
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            const string emailaddress = "emailaddress";

            var identity = new CustomerIdentity(context.Options.AuthenticationType);

            identity.AddClaim(new Claim(emailaddress, context.UserName));


            context.Validated(new AuthenticationTicket(identity, null));
        }
Пример #3
0
        internal static async Task<HttpResponseMessage> GenerateSecureToken(CustomerIdentity identity)
        {
            var pairs = new List<KeyValuePair<string, string>>();

            pairs.Add(new KeyValuePair<string, string>("grant_type", "password"));
            pairs.Add(new KeyValuePair<string, string>("username", identity.Name));
            pairs.Add(new KeyValuePair<string, string>("password", ""));

            try
            {
                var tokenServiceResponse = await tokenServer.HttpClient.PostAsync(
                    Startup.TokenEndPoint,
                    new FormUrlEncodedContent(pairs)
                    );

                return tokenServiceResponse;
            }
            catch (Exception ex)
            {
                //Logger.LogException(ex, "Exception while creating JWT.");
                throw ex;
            }
        }