I'm building a SPA using AngularJS for the client side and the login information is being sent to a ASP.NET WebAPI as an AJAX post. I have the following code in Startup.Auth.cs for the API.
public void ConfigureAuth(IAppBuilder app, IContainer container)
{
var oauthProvider = container.Resolve<IOAuthAuthorizationServerProvider>();
var oauthOptions = new OAuthAuthorizationServerOptions
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/api/RHDevAuth/login"),
Provider = oauthProvider,
AuthorizationCodeExpireTimeSpan = TimeSpan.FromMinutes(1),
AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(3),
SystemClock = new SystemClock()
};
app.UseOAuthBearerTokens(oauthOptions);
}
I'm sending a request to the API that contains the following:
Request Headers:
Http: //mySite/api/login
Content-Type: application/x-www-form-urlencoded
Content-Length: 76
Request Body:
username=steve123%40gmail.com%2C&password=Test222%2C&grant_type=password
The server is responding with an { error: invalid_grant }.
Everything works fine when I run it from local host. However, I get the error when I deploy it to a hosted server account.
What can I do to make this work for either environment?