• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# OAuth.OAuthTokenEndpointContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Owin.Security.OAuth.OAuthTokenEndpointContext的典型用法代码示例。如果您正苦于以下问题:C# OAuthTokenEndpointContext类的具体用法?C# OAuthTokenEndpointContext怎么用?C# OAuthTokenEndpointContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OAuthTokenEndpointContext类属于Microsoft.Owin.Security.OAuth命名空间,在下文中一共展示了OAuthTokenEndpointContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: TokenEndpoint

        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            foreach (var property in context.Properties.Dictionary)
            {
                context.AdditionalResponseParameters.Add(property.Key, property.Value);
            }
            if (!context.AdditionalResponseParameters.ContainsKey("UserId"))
            {
                context.AdditionalResponseParameters.Add("UserId", context.Identity.GetUserId());
            }
            else
            {
                context.AdditionalResponseParameters["UserId"] = context.Identity.GetUserId();
            }

            return Task.FromResult<object>(null);
        }
开发者ID:Fanuer,项目名称:fitnessApp,代码行数:17,代码来源:CustomOAuthProvider.cs


示例17: 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)
        {
         
            var userType = context.OwinContext.Get<string>("user_type");

            context.AdditionalResponseParameters.Add("user_type", userType);


            return Task.FromResult<object>(null);
        }
开发者ID:ns6482,项目名称:practice3,代码行数:19,代码来源:PbAuthorizationServerProvider.cs


示例18: TokenEndpoint

 public override Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     foreach (KeyValuePair<string, string> keyValuePair in context.Properties.Dictionary)
     {
         if (keyValuePair.Key == "isFirstLogin")
         {
             bool result;
             if (!bool.TryParse(keyValuePair.Value, out result))
                 result = false;
             context.AdditionalResponseParameters.Add(keyValuePair.Key, result ? 1 : 0);
         }
         else
             context.AdditionalResponseParameters.Add(keyValuePair.Key, keyValuePair.Value);
     }
     if (context.Properties.Dictionary["as:client_id"] == "MMuaVe")
     {
         var list = context.OwinContext.Get<IList<Claim>>("data:claims");
         if (list != null)
         {
             foreach (KeyValuePair<string, string> keyValuePair in _mobileProfileClaims)
             {
                 KeyValuePair<string, string> profileClaim = keyValuePair;
                 Claim claim = list.FirstOrDefault(m => m.Type == profileClaim.Key);
                 if (claim != null)
                     context.AdditionalResponseParameters.Add(profileClaim.Value, string.IsNullOrEmpty(claim.Value) ? string.Empty : claim.Value);
                 else
                     context.AdditionalResponseParameters.Add(profileClaim.Value, string.Empty);
             }
         }
     }
     return Task.FromResult<object>(null);
 }
开发者ID:quangnc0503h,项目名称:ecommerce,代码行数:32,代码来源:ApplicationOAuthProvider.cs


示例19: TokenEndpoint

 public override async Task TokenEndpoint(OAuthTokenEndpointContext context)
 {
     using (var repo = new AuthRepository())
     {
         var role = context.Identity.Claims.First(c => c.Type == ClaimTypes.Role).Value;
             
         context.AdditionalResponseParameters.Add("role", role);
     }
 }
开发者ID:AndreasFurster,项目名称:kiwi,代码行数:9,代码来源:SimpleAuthorizationServerProvider.cs


示例20: TokenEndpoint

        public override Task TokenEndpoint(OAuthTokenEndpointContext context)
        {
            //Serialize useful information to token here
            if (context.Identity != null)
            {
                var roles = context.Identity.FindAll(ClaimTypes.Role)
                   .Select(x => x.Value)
                   .ToArray();
                var userNameClaim = context.Identity.FindFirst(ClaimTypes.Name);
                var userIdClaim = context.Identity.FindFirst(ClaimTypes.Sid);
                if (userNameClaim == null || userIdClaim == null)
                {
                    throw new InvalidOperationException("User id or user name claim is missing from the identity.");
                }
                context.AdditionalResponseParameters.Add("roles", JsonConvert.SerializeObject(roles));
                context.AdditionalResponseParameters.Add("userName", userNameClaim.Value);
                context.AdditionalResponseParameters.Add("userId", userIdClaim.Value);
            }

            return base.TokenEndpoint(context);
        }
开发者ID:al-main,项目名称:vabank,代码行数:21,代码来源:VabankAuthorizationServerProvider.cs



注:本文中的Microsoft.Owin.Security.OAuth.OAuthTokenEndpointContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap