Notes
Self note on api configurations:
-
To setup token expire span
Startup.Auth.cs >
ConfigureAuth(IAppBuilder app)
{
...
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider(PublicClientId),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
//AllowInsecureHttp = true
};
}
-
To add custom AuthenticationProperties
ApplicationOAuthProvider.cs >
GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
...
var userName = user.UserName;
var fullName = user.FirstName + " " + user.LastName;
var userAccountID = user.Id;
var newProperties = new System.Collections.Generic.List { userName, fullName, userAccountID};
AuthenticationProperties properties = CreateProperties(newProperties);
}
...
CreateProperties(List newProperties)
{
IDictionary data = new Dictionary
{
{ "userName", newProperties[0] },
{ "fullName", newProperties[1] },
{ "userAccountID", newProperties[2] },
};
...
}