public Task<IEnumerable<ValidationResult>> ValidateSettingsAsync(FacebookSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            var results = new List<ValidationResult>();

            if (string.IsNullOrEmpty(settings.AppId))
            {
                results.Add(new ValidationResult(S["The AppId is required."], new[]
                {
                    nameof(settings.AppId)
                }));
            }

            if (string.IsNullOrEmpty(settings.AppSecret))
            {
                results.Add(new ValidationResult(S["The App Secret is required."], new[]
                {
                    nameof(settings.AppSecret)
                }));
            }

            return Task.FromResult<IEnumerable<ValidationResult>>(results);
        }
 public FacebookProvider(
     IHttpClientFactory httpClientFactory,
     IOptions <FacebookSettings> facebookSettings)
 {
     _httpClientFactory = httpClientFactory;
     _facebookSettings  = facebookSettings.Value;
 }
Example #3
0
 //ui
 public FormFacebookApp()
 {
     m_LastSettings = FacebookSettings.LoadFromFile();
     InitializeComponent();
     this.checkBoxRememberUser.Checked = m_LastSettings.RememberUser;
     this.Size = m_LastSettings.LastWindowSize;
 }
Example #4
0
        private void InitializeObjects()
        {
            _facebookSettings = new FacebookSettings
            {
                AppId     = "appId",
                AppSecret = "appSecret"
            };

            _service = new FacebookService(_facebookSettings, _httpService.Object);

            _invalidAccessToken = "Invalid-access-token";

            _validAccessToken = "Valid-access-token";

            _validUserInfoAccessToken = "Valid-user-info-access-token";

            _invalidHttpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.BadRequest
            };

            _validHttpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("{\"data\":{\"app_id\":\"123\",\"type\":\"USER\",\"application\":\"filmunity\",\"data_access_expires_at\":123,\"expires_at\":123,\"is_valid\":true,\"scopes\":[\"email\",\"public_profile\"],\"user_id\":\"123\"}}")
            };

            _validUserInfoHttpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("{\"first_name\":\"Filmunity\",\"last_name\":\"Filmunity\",\"email\":\"email\\u0040email.com\",\"id\":\"123\"}")
            };
        }
Example #5
0
        public static void AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddHttpClient();

            services.AddDbContext <FilmunityDataContext>(options =>
                                                         options.UseSqlServer(configuration.GetConnectionString("FilmunityDatabase")));

            services.AddScoped <IUnitOfWork, UnitOfWork>();

            services.Configure <CloudinarySettings>(configuration.GetSection("CloudinarySettings"));
            services.AddScoped <ICloudUploadService, CloudUploadService>();

            services.Configure <FacebookSettings>(configuration.GetSection("FacebookSettings"));
            var facebookSettings = new FacebookSettings();

            configuration.Bind(nameof(FacebookSettings), facebookSettings);
            services.AddSingleton(facebookSettings);
            services.AddScoped <IFacebookService, FacebookService>();

            services.Configure <OmdbSettings>(configuration.GetSection("OmdbSettings"));
            var omdbSettings = new OmdbSettings();

            configuration.Bind(nameof(OmdbSettings), omdbSettings);
            services.AddSingleton(omdbSettings);
            services.AddScoped <IOmdbService, OmdbService>();

            services.Configure <TwitterSettings>(configuration.GetSection("TwitterSettings"));
            var twitterSettings = new TwitterSettings();

            configuration.Bind(nameof(TwitterSettings), twitterSettings);
            services.AddSingleton(twitterSettings);
            services.AddScoped <TweetSharp.ITwitterService, TweetSharp.TwitterService>();
            services.AddScoped <ITwitterService, TwitterService>();
        }
Example #6
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            FacebookSettings fbSettings = new FacebookSettings {
                ApplicationKey = txtApiKey.Text
            };
            FacebookLoginForm            fbLoginDlg = new FacebookLoginForm(fbSettings);
            FacebookAuthenticationResult fbAuthResult;

            if (fbLoginDlg.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show("You are logged in.");
                fbAuthResult         = fbLoginDlg.FacebookAuthenticationResult;
                txtAccessToken.Text  = fbAuthResult.AccessToken;
                txtExpiresIn.Text    = fbAuthResult.ExpiresIn.ToString();
                btnGetMyInfo.Enabled = true;
            }
            else
            {
                MessageBox.Show("You must login inorder to access Facebook features.");
                if (fbLoginDlg.FacebookAuthenticationResult != null)
                {   // it can be null if the user just cancelled.
                    fbAuthResult = fbLoginDlg.FacebookAuthenticationResult;
                    MessageBox.Show(fbAuthResult.ErrorReasonText);
                }
            }
        }
 public MessengerService(IOptions <FacebookSettings> fbSettings,
                         IMessengerClient messengerClient,
                         IZomatoClient zomatoClient,
                         ILoggerAdapter logger)
 {
     _fbSettings      = fbSettings.Value;
     _messengerClient = messengerClient;
     _zomatoClient    = zomatoClient;
     _logger          = logger;
 }
        public override void OnInspectorGUI()
        {
            instance = (FacebookSettings)target;

            AppIdGUI();
            FBParamsInitGUI();
            AndroidUtilGUI();
            IOSUtilGUI();
            AboutGUI();
            BuildGUI();
        }
        public async Task UpdateSettingsAsync(FacebookSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            var container = await _siteService.LoadSiteSettingsAsync();
            container.Properties[nameof(FacebookSettings)] = JObject.FromObject(settings);
            await _siteService.UpdateSiteSettingsAsync(container);
        }
        public override void OnInspectorGUI()
        {
            instance = (FacebookSettings)target;

            AppIdGUI();
            FBParamsInitGUI();
            AndroidUtilGUI();
            IOSUtilGUI();
            AboutGUI();
            BuildGUI();
        }
Example #11
0
 public AccountController(
     SignInManager <ApplicationUser> signInManager,
     UserManager <ApplicationUser> userManager,
     IOptions <FacebookSettings> facebookSettings,
     IOptions <JwtSettings> jwtSettings,
     IMapper mapper)
 {
     this._signInManager    = signInManager;
     this._userManager      = userManager;
     this._facebookSettings = facebookSettings.Value;
     this._jwtSettings      = jwtSettings.Value;
     this._mapper           = mapper;
     this._client           = new HttpClient();
 }
        private void AppLinksUtilGUI()
        {
            this.showAppLinksSettings = EditorGUILayout.Foldout(this.showAppLinksSettings, "App Links Settings");
            if (this.showAppLinksSettings)
            {
                for (int i = 0; i < FacebookSettings.AppLinkSchemes.Count; ++i)
                {
                    EditorGUILayout.LabelField(string.Format("App Link Schemes for '{0}'", FacebookSettings.AppLabels[i]));
                    List <string> currentAppLinkSchemes = FacebookSettings.AppLinkSchemes[i].Schemes;
                    for (int j = 0; j < currentAppLinkSchemes.Count; ++j)
                    {
                        GUI.changed = false;
                        string scheme = EditorGUILayout.TextField(currentAppLinkSchemes[j]);
                        if (scheme != currentAppLinkSchemes[j])
                        {
                            currentAppLinkSchemes[j] = scheme;
                            FacebookSettings.SettingsChanged();
                        }

                        if (GUI.changed)
                        {
                            ManifestMod.GenerateManifest();
                        }
                    }

                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Add a Scheme"))
                    {
                        FacebookSettings.AppLinkSchemes[i].Schemes.Add(string.Empty);
                        FacebookSettings.SettingsChanged();
                    }

                    if (currentAppLinkSchemes.Count > 0)
                    {
                        if (GUILayout.Button("Remove Last Scheme"))
                        {
                            FacebookSettings.AppLinkSchemes[i].Schemes.Pop();
                        }
                    }

                    EditorGUILayout.EndHorizontal();
                }
            }
        }
Example #13
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            FacebookSettings fbSettings = new FacebookSettings { ApplicationKey = txtApiKey.Text };
            FacebookLoginForm fbLoginDlg = new FacebookLoginForm(fbSettings);
            FacebookAuthenticationResult fbAuthResult;

            if (fbLoginDlg.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show("You are logged in.");
                fbAuthResult = fbLoginDlg.FacebookAuthenticationResult;
                txtAccessToken.Text = fbAuthResult.AccessToken;
                txtExpiresIn.Text = fbAuthResult.ExpiresIn.ToString();
                btnGetMyInfo.Enabled = true;
            }
            else
            {
                MessageBox.Show("You must login inorder to access Facebook features.");
                if (fbLoginDlg.FacebookAuthenticationResult != null)
                {   // it can be null if the user just cancelled.
                    fbAuthResult = fbLoginDlg.FacebookAuthenticationResult;
                    MessageBox.Show(fbAuthResult.ErrorReasonText);
                }
            }
        }
Example #14
0
 public MessengerClient(HttpClient httpClient,
                        IOptions <FacebookSettings> fbSettings)
 {
     _httpClient = httpClient;
     _fbSettings = fbSettings.Value;
 }
Example #15
0
 public FacebookService(FacebookSettings facebookSettings, IHttpService httpService)
 {
     _facebookSettings = facebookSettings;
     _httpService      = httpService;
 }
Example #16
0
 public Facebook()
 {
     Initalize();
     Settings = new FacebookSettings();
     NavigateTo(Url);
 }
Example #17
0
 public void ReSaveSettings()
 {
     FacebookSettings.SaveSettingsFromFile(_configFilePath, Settings);
 }
 public FacebookClient(FacebookSettings settings)
 {
     Settings = settings;
 }
 public FacebookSettingsEditor()
 {
     FacebookSettings.RegisterChangeEventCallback(this.SettingsChanged);
 }
        private void AppIdGUI()
        {
            EditorGUILayout.LabelField("Add the Facebook App Id(s) associated with this game");
            if (FacebookSettings.AppIds.Count == 0 || FacebookSettings.AppId == "0")
            {
                EditorGUILayout.HelpBox("Invalid App Id", MessageType.Error);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(this.appNameLabel);
            EditorGUILayout.LabelField(this.appIdLabel);
            EditorGUILayout.EndHorizontal();
            for (int i = 0; i < FacebookSettings.AppIds.Count; ++i)
            {
                EditorGUILayout.BeginHorizontal();
                FacebookSettings.AppLabels[i] = EditorGUILayout.TextField(FacebookSettings.AppLabels[i]);
                GUI.changed = false;
                FacebookSettings.AppIds[i] = EditorGUILayout.TextField(FacebookSettings.AppIds[i]);
                if (GUI.changed)
                {
                    FacebookSettings.SettingsChanged();
                    ManifestMod.GenerateManifest();
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Another App Id"))
            {
                FacebookSettings.AppLabels.Add("New App");
                FacebookSettings.AppIds.Add("0");
                FacebookSettings.AppLinkSchemes.Add(new FacebookSettings.UrlSchemes());
                FacebookSettings.SettingsChanged();
            }

            if (FacebookSettings.AppLabels.Count > 1)
            {
                if (GUILayout.Button("Remove Last App Id"))
                {
                    FacebookSettings.AppLabels.Pop();
                    FacebookSettings.AppIds.Pop();
                    FacebookSettings.AppLinkSchemes.Pop();
                    FacebookSettings.SettingsChanged();
                }
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            if (FacebookSettings.AppIds.Count > 1)
            {
                EditorGUILayout.HelpBox("2) Select Facebook App Id to be compiled with this game", MessageType.None);
                GUI.changed = false;
                FacebookSettings.SelectedAppIndex = EditorGUILayout.Popup(
                    "Selected App Id",
                    FacebookSettings.SelectedAppIndex,
                    FacebookSettings.AppIds.ToArray());
                if (GUI.changed)
                {
                    ManifestMod.GenerateManifest();
                }

                EditorGUILayout.Space();
            }
            else
            {
                FacebookSettings.SelectedAppIndex = 0;
            }
        }
 public FacebookLoginForm(FacebookSettings facebookSettings)
 {
     _loginUri = new Uri(facebookSettings.DesktopLoginUrl);
     InitializeComponent();
 }
Example #22
0
 public FacebookController(FacebookSettings facebookSettings, ISettingService settingService)
 {
     _facebookSettings = facebookSettings;
     _settingService   = settingService;
 }
 public static void Register()
 {
     // Loads the settings from web.config using the following app setting keys:
     // Facebook.AppId, Facebook.AppSecret, Facebook.AppNamespace, Facebook.RealtimeCallbackUrl
     FacebookSettings.LoadFromConfig();
 }
Example #24
0
 public FacebookService(FacebookSettings facebookSettings, IFacebookClient facebookClient, IMapper mapper)
 {
     _facebookSettings = facebookSettings;
     _facebookClient   = facebookClient;
     _mapper           = mapper;
 }
Example #25
0
 public FacebookService(IFacebookClient facebookClient, FacebookSettings facebookSettings)
 {
     _facebookClient   = facebookClient;
     _facebookSettings = facebookSettings;
 }
 public FacebookUserQuery CreateFacebookUserQuery(FacebookSettings facebookSettings)
 {
     return new FacebookUserQuery(facebookSettings);
 }
Example #27
0
 public FacebookLoginForm(FacebookSettings facebookSettings)
 {
     _loginUri = new Uri(facebookSettings.DesktopLoginUrl);
     InitializeComponent();
 }
Example #28
0
 public ServusFacebook(string configFilePath)
 {
     _configFilePath = configFilePath;
     Settings        = FacebookSettings.LoadSettingsFromFile(configFilePath);
     Fbuserdata      = new FbUserdata();
 }
 public ExternalAccountService(IOptions <FacebookSettings> fbSettings, UserManager <User> userManager, IHttpContextAccessor accessor, IOptions <GeoLocationSettings> geoLocationSettings, IOptions <JwtSettings> jwtSettings, ILogger <BaseService> logger, IMapper mapper, IRepository <User> userRepository, IRepository <LoginInfo> loginInfoRepository, SignInManager <User> signInManager) : base(userManager, accessor, geoLocationSettings, jwtSettings, logger, mapper, userRepository, loginInfoRepository, signInManager)
 {
     this.fbSettings = fbSettings.Value;
 }
 public FacebookUserRepository(FacebookSettings facebookSettings)
 {
     _facebookSettings = facebookSettings;
 }