I have an ASP.NET Web API and I registered a new Application under Azure Active Directory.
This is how the ConfigureAuth is in the source code of the Web API.
public void ConfigureAuth(IAppBuilder app)
{
// Configure the db context and user manager to use a single instance per request
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
// Configure the application for OAuth based flow
OAuthOptions = new OAuthAuthorizationServerOptions
{
AllowInsecureHttp = false,
TokenEndpointPath = new PathString("/Token"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
Provider = new ApplicationOAuthProvider("self"),
AuthenticationType = "LocalBearer"
};
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(OAuthOptions);
}
On the other hand, I have a command line application that access to the Web API and ask some data to it.
From the command line I can't login using users credentials (this is a requirement) so I would like to generate a Personal Access Token that expires maybe in a year or two and construct my API call with that Personal Access Token. If that's possible then I can avoid to sign in with a username/password to generate a Token.
Is there any documentation on this scenario? How can I generate Personal Access Tokens for my Console Application to connect to a Web API hosted in Azure?