Obi1-Cannabis 0 Posted October 16, 2015 Report Share Posted October 16, 2015 Is it possible to extend the OAuthGrantResourceOwnerCredentialsContext class from Microsoft.Owin.Security.OAuth? when implementing my custom OAuthProvider I want to be able to add a new IList to the context in order to send messages that will be intercepted by Growl in AngularJs. what i want to do in case of an error for example is something like: public class CustomOAuthProvider : OAuthAuthorizationServerProviderExtended{ //removed code for brevity public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContextExtended context) { //removed code for brevity ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password); if (user == null) { context.messages.Add(GeneralEx.CreateGrowlMessage("The company, user name or password is incorrect.", "error")); return; } //removed code for brevity }} where CreateGrowlMessage is public static GrowlMessage CreateGrowlMessage(string message, string severity) { GrowlMessage growlMessage = new GrowlMessage(); growlMessage.text = message; growlMessage.severity = severity; return growlMessage; } and GrowlMessage is public class GrowlMessage{ public string text; public string severity;} I was trying to extend both OAuthAuthorizationServerProvider and OAuthGrantResourceOwnerCredentialsContext shown bellow public class OAuthAuthorizationServerProviderExtended : OAuthAuthorizationServerProvider { public virtual Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContextExtended context) { return Task.FromResult<object>(null); } } public class OAuthGrantResourceOwnerCredentialsContextExtended : OAuthGrantResourceOwnerCredentialsContext { public OAuthGrantResourceOwnerCredentialsContextExtended(IOwinContext context, OAuthAuthorizationServerOptions options, string clientId, string userName, string password, IList<string> scope) : base(context, options, clientId, userName, password, scope) { } public IList<GrowlMessage> messages {get;set;} } but this is not having the desired effect. now all login attempts fail and all i get in the response is {"error":"invalid_grant"} Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.