當前位置: 首頁>>代碼示例>>C#>>正文


C# OAuth.OAuthTokenEndpointContext類代碼示例

本文整理匯總了C#中Microsoft.Owin.Security.OAuth.OAuthTokenEndpointContext的典型用法代碼示例。如果您正苦於以下問題:C# OAuthTokenEndpointContext類的具體用法?C# OAuthTokenEndpointContext怎麽用?C# OAuthTokenEndpointContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OAuthTokenEndpointContext類屬於Microsoft.Owin.Security.OAuth命名空間,在下文中一共展示了OAuthTokenEndpointContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TokenEndpoint

        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            foreach (var claim in context.Identity.Claims)
            {
                if (claim.Type == ClaimTypes.Email)
                {
                    context.AdditionalResponseParameters.Add("email", claim.Value);
                }

                if (claim.Type == ClaimTypes.Role)
                {
                    context.AdditionalResponseParameters.Add("role", claim.Value);
                }

                if (claim.Type == ClaimTypes.MobilePhone)
                {
                    context.AdditionalResponseParameters.Add("mobile_number", claim.Value);
                }

                if (claim.Type == ClaimTypes.Country)
                {
                    context.AdditionalResponseParameters.Add("country", claim.Value);
                }

                if(claim.Type == "MobileNumberConfirmed")
                {
                    context.AdditionalResponseParameters.Add("mobile_number_confirmed", claim.Value);
                }
            }

            return Task.FromResult<object>(null);
        }
開發者ID:mustee,項目名稱:Voting,代碼行數:32,代碼來源:AuthorizationServerProvider.cs

示例2: TokenEndpoint

 public override async Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     foreach (KeyValuePair<string, string> property in context.Properties.Dictionary)
     {
         context.AdditionalResponseParameters.Add(property.Key, property.Value);
     }
 }
開發者ID:dude3133,項目名稱:Abit-info,代碼行數:7,代碼來源:ApplicationOAuthProvider.cs

示例3: TokenEndpoint

        public override Task TokenEndpoint(OAuthTokenEndpointContext context) {
            foreach (KeyValuePair<string, string> property in context.Properties.Dictionary) {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            return Task.FromResult<object>(null);
        }
開發者ID:sarahywloo,項目名稱:BigFixer,代碼行數:7,代碼來源:ApplicationOAuthProvider.cs

示例4: TokenEndpoint

 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     var isFilledClaim = context.Identity.Claims.FirstOrDefault(x => x.Type == "profileFiled");
     if (isFilledClaim != null)
     {
         var isFilled = isFilledClaim.Value;
         context.AdditionalResponseParameters.Add("isFilled",bool.Parse(isFilled));
     }
     return base.TokenEndpoint(context);
 }
開發者ID:DrNorton,項目名稱:GoSmoke,代碼行數:10,代碼來源:SimpleAuthorizationServerProvider.cs

示例5: TokenEndpoint

 /// <summary>
 /// Is used to add additional return values to the token response message
 /// </summary>
 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     foreach (var property in context.Properties.Dictionary)
     {
         context.AdditionalResponseParameters.Add(property.Key, property.Value);
     }
     //var userSessionClaim = context.Identity.FindFirst(claim => claim.Type == ApiConstants.Claims.UserSessionID);
     //context.AdditionalResponseParameters.Add(userSessionClaim.Type, userSessionClaim.Value);
     return Task.FromResult<object>(null);
 }
開發者ID:basharathussain,項目名稱:doctors_app,代碼行數:13,代碼來源:AuthorizationServerProvider.cs

示例6: TokenEndpoint

        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {

            #region " Getting time to update service country and lease time "
            Int32 UpdateTimeInMinutes = 5;
            if (WebConfigurationManager.AppSettings["UpdateTimeInMinutes"] != null && WebConfigurationManager.AppSettings["UpdateTimeInMinutes"].Trim().Length > 0)
            {
                UpdateTimeInMinutes = Convert.ToInt32(WebConfigurationManager.AppSettings["UpdateTimeInMinutes"].Trim());
            }
            #endregion

            #region " Getting Token Expiry Time from Config file "
            Int32 days = 0;
            if (WebConfigurationManager.AppSettings["ExpiryDateTimeInDays"] != null && WebConfigurationManager.AppSettings["ExpiryDateTimeInDays"].Trim().Length > 0)
            {
                days = Convert.ToInt32(WebConfigurationManager.AppSettings["ExpiryDateTimeInDays"].Trim());
            } 
            #endregion

            #region " Assigning Token Expiry Time "
            foreach (KeyValuePair<string, string> property in context.Properties.Dictionary)
            {
                //.expires
                if (property.Key == ".expires")
                {
                    context.AdditionalResponseParameters.Add(property.Key, DateTime.Today.AddDays(days));
                }
                else if (property.Key == "expires_in")
                {
                    int seconds = days * 60 * 60;
                    context.AdditionalResponseParameters.Add(property.Key, seconds);
                }
                else
                {
                    context.AdditionalResponseParameters.Add(property.Key, property.Value);
                }

            } 
            #endregion

            #region " Writting values in Response object "
            context.AdditionalResponseParameters.Add("userName", userADName);
            context.AdditionalResponseParameters.Add("userEmail", userADEmail);
            context.AdditionalResponseParameters.Add("userPhone", userADPhone);
            context.AdditionalResponseParameters.Add("UpdateTimeInMinutes", UpdateTimeInMinutes); 
            #endregion
            return Task.FromResult<object>(null);
        }
開發者ID:Kashifabbas,項目名稱:Finance.Services,代碼行數:48,代碼來源:ApplicationOAuthProvider.cs

示例7: TokenEndpoint

        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var claims = context.Identity.Claims.ToArray();
            foreach (var claim in claims)
            {
                if (claim.ValueType == "self")
                {
                    context.AdditionalResponseParameters[claim.Type] = claim.Value;
                    context.Identity.RemoveClaim(claim);
                }
            }
            return base.TokenEndpoint(context);
        }
開發者ID:mparsin,項目名稱:Elements,代碼行數:18,代碼來源:SimpleAuthorizationServerProvider.cs

示例8: TokenEndpoint

 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     foreach (KeyValuePair<string, string> property in context.Properties.Dictionary)
     {
         context.AdditionalResponseParameters.Add(property.Key, property.Value);
     }
     # region Response back some additional parameters by using /Token method OR Identity
     if (HttpContext.Current.Request.Browser["IsMobileDevice"] == "true")
     {
         context.AdditionalResponseParameters.Add("AntiForgeryToken", deviceId);
     }
     else 
     {
         context.AdditionalResponseParameters.Add("AntiForgeryToken", ip);
     }
     #endregion
     return Task.FromResult<object>(null);
 }
開發者ID:syatin003,項目名稱:stepan_api_first,代碼行數:18,代碼來源:ApplicationOAuthProvider.cs

示例9: TokenEndpoint

        public override async Task TokenEndpoint(OAuthTokenEndpointContext context)
        {


           
                context.AdditionalResponseParameters.Add("empresaId", _usuario.EmpresaId);
                context.AdditionalResponseParameters.Add("ImagemUsuario", _usuario.ImagemUsuario);
                context.AdditionalResponseParameters.Add("EmpresaImagem", _usuario.Empresa.EmpresaImagem);
                context.AdditionalResponseParameters.Add("NomeEmpresa", _usuario.Empresa.NomeEmpresa);

            foreach (var role in _roles)
            {
                context.AdditionalResponseParameters.Add("roles", role.Key);
                context.AdditionalResponseParameters.Add("IdRole", role.Value);
            }

            await Task.FromResult(context);

        }
開發者ID:YuleSouza,項目名稱:Loja,代碼行數:19,代碼來源:AuthAuthorizationServerProvider.cs

示例10: TokenEndpoint

        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            var issued = context.Properties.Dictionary[".issued"];
            var expires = context.Properties.Dictionary[".expires"];
            var roles = context.Properties.Dictionary["roles"];
            var userId = context.Properties.Dictionary["userId"];
            var userName = context.Properties.Dictionary["userName"];
            var firstName = context.Properties.Dictionary["firstName"];
            var lastName = context.Properties.Dictionary["lastName"];

            context.AdditionalResponseParameters.Add(".issued", issued);
            context.AdditionalResponseParameters.Add(".expires", expires);
            context.AdditionalResponseParameters.Add("roles", roles);
            context.AdditionalResponseParameters.Add("userId", userId);
            context.AdditionalResponseParameters.Add("userName", userName);
            context.AdditionalResponseParameters.Add("firstName", firstName);
            context.AdditionalResponseParameters.Add("lastName", lastName);

            return Task.FromResult<object>(null);
        }
開發者ID:eddievagabond,項目名稱:angular-oauth-base,代碼行數:20,代碼來源:CustomOAuthProvider.cs

示例11: TokenEndpoint

 public Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     throw new NotImplementedException();
 }
開發者ID:RolandTG,項目名稱:OwinSamples,代碼行數:4,代碼來源:AuthorizationServerProvider.cs

示例12: TokenEndpoint

        /// <summary>
        /// Called at the final stage of a successful Token endpoint request. An application may implement this call in order to do any final 
        /// modification of the claims being used to issue access or refresh tokens. This call may also be used in order to add additional 
        /// response parameters to the Token endpoint's json response body.
        /// </summary>
        /// <param name="context">The context of the event carries information in and results out.</param>
        /// <returns>Task to enable asynchronous execution</returns>
        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            // Add all entries that we've added to the validated ticket (using the AuthenticationProperties):
            foreach (KeyValuePair<string, string> property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }

            return Task.FromResult<object>(null);
        }
開發者ID:nicolaihald,項目名稱:OAuthDemo,代碼行數:17,代碼來源:DemoAuthorizationServerProvider.cs

示例13: TokenEndpoint

 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     foreach (KeyValuePair<string, string> property in context.Properties.Dictionary)
     {
         context.AdditionalResponseParameters.Add(property.Key, property.Value);
     }
     //to jest tymczasowe rozwiązanie , czyli pewnie juz tak zostanie 
     context.AdditionalResponseParameters.Add("roles",
         context.Identity.Name == "Admin" ? "Admin" : "User");
     return Task.FromResult<object>(null);
 }
開發者ID:Gangrena,項目名稱:WebBellwether,代碼行數:11,代碼來源:SimpleAuthorizationServerProvider.cs

示例14: TokenEndpoint

 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     //Called at the final stage of a successful Token endpoint request. do any final modification of the claims being used to issue access or refresh tokens
     return base.TokenEndpoint(context);
 }
開發者ID:cecilphillipTK,項目名稱:webapi2-security-samples,代碼行數:5,代碼來源:CustomAuthorizationServerProvider.cs

示例15: TokenEndpoint

 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     foreach (KeyValuePair<string, string> keyValuePair in (IEnumerable<KeyValuePair<string, string>>)context.Properties.Dictionary)
         context.AdditionalResponseParameters.Add(keyValuePair.Key, (object)keyValuePair.Value);
     return (Task)Task.FromResult<object>((object)null);
 }
開發者ID:quangnc0503h,項目名稱:ecommerce,代碼行數:6,代碼來源:CaptchaOAuthProvider.cs


注:本文中的Microsoft.Owin.Security.OAuth.OAuthTokenEndpointContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。