Hello, I'm starting my studies with OAuth, and right away I came across a problem. I created the famous 'Startup' class, and I call it my provider as follows:
public partial class Startup
{
public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; }
public void Configuration(IAppBuilder app)
{
app.UseOAuthBearerTokens(OAuthOptions);
}
static Startup()
{
OAuthOptions = new OAuthAuthorizationServerOptions
{
AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/autenticar"),
/*chamada do provider*/
Provider = new OAuthProvider()
};
}
}
But the constructor of this class applies a dependency injection in the constructor as follows:
IUsuariosServices _usuariosServices;
public OAuthProvider(IUsuariosServices usuariosServices)
{
_usuariosServices = usuariosServices;
}
In order to perform the functions inserted in this interface.
Looking like this:
public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
return Task.Factory.StartNew(() =>
{
string email = context.UserName;
string senha = context.Password;
/* Chamada da função da injeção de dependências */
var usuario = _usuariosServices.Login(email, senha);
});
}
But in my 'Startup' class, in the call of the provider class an error occurs asking for a parameter of the class!
error message
The problem is? What is this? How to pass dependency injection as a parameter? Is that what you have to do?
Thank you in advance ...