// Initializes provider with custom name
        public CivicIDOAuthClient(string providerName, AppInfo appInfo, EndPointsConfig endPoints)
            : base(providerName)
        {
            if (appInfo == null)
                throw new Exception("Application Info is required");

            if (endPoints == null)
                throw new Exception("End-points are required");

            this.EndPoints = endPoints;
            this.AppInfo = appInfo;

            if (string.IsNullOrEmpty(appInfo.ApplicationId))
                throw new Exception("Application Id is required");

            if (string.IsNullOrEmpty(appInfo.ApplicationSecret))
                throw new Exception("Application Secret is required");

            if (string.IsNullOrEmpty(appInfo.Environment))
                throw new Exception("Environment is required");

            var scopeList = new List<string>();

            if (endPoints.UserProfileEndPoint.Contains("v3"))
                _profileScope = "get_user_profile";
            else if (endPoints.UserProfileEndPoint.Contains("v4"))
                _profileScope = "get_my_profile";

            if (this.AppInfo.Scopes != null
                && this.AppInfo.Scopes.Any())
            {
                // check to see if this.Scope already has get_user_profile. If not, add profile scope
                if (!Array.Exists(this.AppInfo.Scopes, delegate(string str) { return str.Equals(_profileScope, StringComparison.OrdinalIgnoreCase); }))
                {
                    // add profile scope
                    scopeList.Add(_profileScope);
                }

                // copy over scopes passed in by the client
                scopeList.AddRange(this.AppInfo.Scopes);
            }
            else
                scopeList.Add(_profileScope);

            this.AppInfo.Scopes = scopeList.ToArray();
        }
        public static void RegisterAuth()
        {
            // To let users of this site log in using their accounts from  other sites such as Microsoft, Facebook, and Twitter,
            // you must update this site. For more information visit http://go.microsoft.com/fwlink/?LinkID=252166

            //OAuthWebSecurity.RegisterMicrosoftClient(
            //    clientId: "",
            //    clientSecret: "");

            //OAuthWebSecurity.RegisterTwitterClient(
            //    consumerKey: "",
            //    consumerSecret: "");

            //OAuthWebSecurity.RegisterFacebookClient(
            //    appId: "",
            //    appSecret: "");

            var appInfo = new AppInfo
            {
                AgencyName = ConfigurationManager.AppSettings["agencyId"],
                ApplicationId = ConfigurationManager.AppSettings["appId"],
                ApplicationSecret = ConfigurationManager.AppSettings["appSecret"],
                Environment = "TEST", //e.g. TEST, PROD
                Scopes = new string[] { "records", "get_record_contacts" }
            };

            var endPoints = new EndPointsConfig
            {
                AuthorizationEndPoint = "https://auth.accela.com/oauth2/authorize", //e.g. "https://auth.accela.com/oauth2/authorize"
                TokenEndPoint = "https://apis.accela.com/oauth2/token", //e.g. "https://apis.accela.com/oauth2/token"
                UserProfileEndPoint = "https://apis.accela.com/v3/users/me", //e.g. "https://apis.accela.com/v3/users/me"
            };

            OAuthWebSecurity.RegisterClient(
                new CivicIDOAuthClient(appInfo, endPoints), "Civic ID", null);

            //OAuthWebSecurity.RegisterGoogleClient();
        }
 // Initializes provider with the default name: CivicIDProvider
 public CivicIDOAuthClient(AppInfo appInfo, EndPointsConfig endPoints)
     : this("CivicIDProvider", appInfo, endPoints)
 {
 }