예제 #1
0
        public static void SetContextByConifg(OAuth2Context context)
        {
            var     value = configuration[string.Format("OAuth2Authorize:{0}", context.ConfigKey)];
            Context result;

            if (!m_Contexts.TryGetValue(value, out result))
            {
                string id = null, secret = null;
                var    match = m_rId.Match(value);
                if (match.Success)
                {
                    id = match.Groups[1].Value.Trim();
                }
                else
                {
                    throw new Exception("配置中不包含id值");
                }
                match = m_rSecret.Match(value);
                if (match.Success)
                {
                    secret = match.Groups[1].Value.Trim();
                }
                else
                {
                    throw new Exception("配置中不包含secret值");
                }
                result = new Context(id, secret);
            }
            context.Set(result);
        }
예제 #2
0
 public OAuth2Identity(OAuth2Context context, string accessToken, string scope)
     : base(context)
 {
     this.access_token = accessToken;
     this.scope        = scope;
 }
예제 #3
0
 public OAuth2Identity(OAuth2Context context, string accessToken)
     : this(context, accessToken, null)
 {
 }
예제 #4
0
 public OAuth2ClientIdentity(OAuth2Context context)
     : this(context.ClientId, context.ClientSecret)
 {
 }
예제 #5
0
 public static void Load(string configKey)
 {
     m_Current = new OAuth2Context(configKey);
 }