Quelle est l'implémentation OAuth AccessTokenFormat par défaut dans OWIN pour l'hôte IIS?

Web API 2 OWIN Porteur du jeton d'authentification - AccessTokenFormat null?

La valeur par défaut /Jeton points de terminaison fonctionne très bien et j'ai pu obtenir un jeton à partir de là,
mais j'ai besoin d'utiliser la AccessTokenFormat.Protéger méthode sur un billet de générer accessToken pour externalLogin.

Fondamentalement, mon œuvre est à peu près le même que celui-ci, et j'ai rencontré le même problème de l'AccessTokenFormat est null.
À partir de la la documentation il dit:

Le format de données utilisé pour protéger les informations contenues dans le jeton d'accès. Si pas fourni par l'application par défaut fournisseur de protection des données dépend de l'hôte du serveur. Le SystemWeb hôte sur services internet (IIS) utilisation ASP.NET la machine clé de la protection des données, et HttpListener et d'autres auto-hébergés les serveurs de l'utilisation DPAPI la protection des données. Si un jeton d'accès différents fournisseur ou le format est assignée, compatible instance doit être attribué à la OAuthBearerAuthenticationOptions.AccessTokenProvider ou OAuthBearerAuthenticationOptions.AccessTokenFormat propriété de la ressource serveur.

Il me semble que si le AccessTokenFormat n'est pas affecté, l'hôte serait de fournir une implémentation de base. Mais je ne vois pas qu'il travaille ici.
Est-il un moyen que je pourrais trouver le défaut de mise en œuvre de la ISecureDataFormatAccessTokenFormat et l'affecter à la variable manuellement?

Ou quelqu'un a d'autres idées sur la façon de résoudre ce problème?

Mise à JOUR:
Je reçois le code source de katana et de trouver la OAuthAuthorizationServerMiddleware classe, à partir du code source, j'ai pu voir le code suivant:

if (Options.AccessTokenFormat == null)
        {
            IDataProtector dataProtecter = app.CreateDataProtector(
                typeof(OAuthAuthorizationServerMiddleware).Namespace,
                "Access_Token", "v1");
            Options.AccessTokenFormat = new TicketDataFormat(dataProtecter);
        }

Dans mon Démarrage.Auth, voici mon code:

     static Startup()
{
PublicClientId = "self";
UserManagerFactory = () => new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
OAuthOptions = new OAuthAuthorizationServerOptions()
{
TokenEndpointPath = new PathString("/Token"),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
Provider = new ApplicationOAuthProvider(PublicClientId, UserManagerFactory),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
AllowInsecureHttp = true
};
OAuthBearerOptions = new OAuthBearerAuthenticationOptions();
OAuthBearerOptions.AccessTokenFormat = OAuthOptions.AccessTokenFormat;
OAuthBearerOptions.AccessTokenProvider = OAuthOptions.AccessTokenProvider;
OAuthBearerOptions.AuthenticationMode = OAuthOptions.AuthenticationMode;
OAuthBearerOptions.AuthenticationType = OAuthOptions.AuthenticationType;
OAuthBearerOptions.Description = OAuthOptions.Description;
OAuthBearerOptions.Provider = new CustomBearerAuthenticationProvider();
OAuthBearerOptions.SystemClock = OAuthOptions.SystemClock;
}
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);
app.UseOAuthAuthorizationServer(OAuthOptions);
//Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(OAuthOptions);
//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
//Configure the sign in cookie
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
//Use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

}

J'ai aussi de la suite dans WebApiConfig

//Web API configuration and services
//Configure Web API to use only bearer token authentication.
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

Je ne sais pas pourquoi
app.UseOAuthAuthorizationServer(OAuthOptions); n'est pas le réglage de la accessTokenFormat

source d'informationauteur Wei