async Task method() { var auth = new FacebookAuthenticator( "2063574180384090", "email", this); var authenticator = auth.GetAuthenticator(); var viewController = authenticator.GetUI(); _navigationStack = ((AppDelegate)_Managers[0]).Window.RootViewController; SafariServices.SFSafariViewController c = null; c = (SafariServices.SFSafariViewController)viewController; viewController = c; _navigationStack.PresentViewController(viewController, true, null); //if (result.Authenticated) //{ // ExecuteCallBack(new FingerPrint { IsValid = true }); //} //else //{ // OnError(new string[] { ServiceKey + " Reported " + result.Status.ToString(), result.ErrorMessage }); //} }
public async Task Test_FacebookController_NoUserToken_Fail() { //Arrange //Facebook User Token absent FacebookAuthModel facebookAuthModel = new FacebookAuthModel(); FacebookAuthenticator authenticator = new FacebookAuthenticator(this.MockFacebookClient.Object); var securityService = new SecurityService <FacebookAuthModel>(this.SecuritySettings); var controller = new FacebookController(securityService, authenticator); try { //Act var result = await controller.Create(facebookAuthModel); } catch (SecurityException ex) { //Assert Assert.IsType <SecurityException>(ex); this.MockFacebookClient.Verify(x => x.PostSecurityRequest(facebookAuthModel), Times.Never); } }
public async Task Test_FacebookController_Pass() { //Arrange FacebookAuthModel facebookAuthModel = new FacebookAuthModel { UserAccessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }; var client = new FacebookClient(this.SecuritySettings, this.MockHttpClient.Object); FacebookAuthenticator authenticator = new FacebookAuthenticator(client); var securityService = new SecurityService <FacebookAuthModel>(this.SecuritySettings); var controller = new FacebookController(securityService, authenticator); //Act var result = await controller.Create(facebookAuthModel); //Assert Assert.IsType <ObjectResult>(result); Assert.True((result as ObjectResult).Value.ToString().IsValidJwtToken()); this.MockHttpClient.Verify(x => x.GetStringAsync <FacebookAppAccessToken>(It.IsAny <string>()), Times.Once); this.MockHttpClient.Verify(x => x.GetStringAsync <FacebookUserAccessTokenValidation>(It.IsAny <string>()), Times.Once); }
void OnFacebookLoginButtonClicked(object sender, EventArgs e) { var auth = new FacebookAuthenticator(FacebookConfiguration.ClientId, FacebookConfiguration.Scope, this); // Display the activity handling the authentication StartSocialAuth(auth); }
public async Task Test_FacebookController_FacebookAuth_Fail() { //Arrange //Facebook Client returns IsAuthenticated false this.MockFacebookClient = this.InitMockFacebookClient(this.SecuritySettings, false); FacebookAuthModel facebookAuthModel = new FacebookAuthModel { UserAccessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }; FacebookAuthenticator authenticator = new FacebookAuthenticator(this.MockFacebookClient.Object); var securityService = new SecurityService <FacebookAuthModel>(this.SecuritySettings); var controller = new FacebookController(securityService, authenticator); //Act var result = await controller.Create(facebookAuthModel); //Assert Assert.IsType <BadRequestResult>(result); this.MockFacebookClient.Verify(x => x.PostSecurityRequest(facebookAuthModel), Times.Once); }
public void OnClickFacebookSignIn() { FacebookAuthenticator.GetAuthCode(facebookCode => { FacebookAuthenticator.ExchangeAuthCodeWithIdToken(facebookCode, accessToken => { FirebaseAuthHandler.SingInWithToken(accessToken, "facebook.com", true); }); }); }
private void OnFacebookLoginButtonClicked(object sender, EventArgs e) { var auth = new FacebookAuthenticator(Configuration.ClientId, Configuration.Scope, this); var authenticator = auth.GetAuthenticator(); var viewController = authenticator.GetUI(); PresentViewController(viewController, true, null); }
private void StartFacebookAuth(object sender, EventArgs e) { _facebookAuthenticator = new FacebookAuthenticator(Configuration.ClientId, Configuration.Scope, ViewModel); Xamarin.Auth.OAuth2Authenticator authenticator = _facebookAuthenticator.GetAuthenticator(); UIViewController view = authenticator.GetUI(); PresentViewController(view, true, null); }
private void OnFacebookLoginButtonClicked(object sender, EventArgs e) { _authFacebook = new FacebookAuthenticator(Configuration.ClientId, Configuration.Scope, ViewModel); Xamarin.Auth.OAuth2Authenticator authenticator = _authFacebook.GetAuthenticator(); Intent intent = authenticator.GetUI(Activity); StartActivity(intent); }
public IHttpActionResult GetExternalLoginUris() { return(this.Ok(new { Facebook = FacebookAuthenticator.GetUri(), Google = GoogleAuthenticator.GetUri(), Twitter = TwitterAuthenticator.GetUri() })); }
partial void FacebookLoginButton_TouchUpInside(UIButton sender) { //animate indicator FacebookConnectedImage.Image = UIImage.FromBundle("loading-indicator"); Platform.AnimateRotation(FacebookConnectedImage); //push fb login var auth = new FacebookAuthenticator(Configuration.FbClientId, Configuration.Scope, this); var authenticator = auth.GetAuthenticator(); var viewController = authenticator.GetUI(); PresentViewController(viewController, true, null); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); _auth = new FacebookAuthenticator(Configuration.ClientId, Configuration.Scope, this); var facebookLoginButton = FindViewById <Button>(Resource.Id.facebookLoginButton); facebookLoginButton.Click += OnFacebookLoginButtonClicked; }
public override void OnViewModelChanged(object sender, PropertyChangedEventArgs e) { base.OnViewModelChanged(sender, e); if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.FBLoaderImage)) { if (ViewModel.IsBusy) { AnimateImage(twitterNetworkLoader); var auth = new FacebookAuthenticator(Configuration.FbClientId, Configuration.Scope, ViewModel); var authenticator = auth.GetAuthenticator(); var intent = authenticator.GetUI(this.Activity); this.StartActivity(intent); AnimateImage(fbNetworkLoader); } if (!ViewModel.IsBusy) { fbNetworkLoader.ClearAnimation(); } ChangeSocialNetworkTextColor(); } if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.TwitterLoaderImage)) { if (ViewModel.IsBusy) { var auth = new TwitterAuthentificator(Configuration.ConsumerKeyTwitter, Configuration.ConsumerSecretTwitter, Configuration.Scope, ViewModel); var authenticator = auth.GetAuthenticator(); var intent = authenticator.GetUI(this.Activity); this.StartActivity(intent); AnimateImage(twitterNetworkLoader); } if (!ViewModel.IsBusy) { twitterNetworkLoader.ClearAnimation(); } ChangeSocialNetworkTextColor(); } if (e.PropertyName == PropertiesExtension.GetPropertyName(() => ViewModel.InstaLoaderImage)) { if (ViewModel.IsBusy) { var auth = new InstagramAuthenticator(Configuration.ConsumerKeyInsta, string.Empty, Configuration.InstaScope, ViewModel); var authenticator = auth.GetAuthenticator(); var intent = authenticator.GetUI(this.Activity); this.StartActivity(intent); AnimateImage(instaNetworkLoader); } if (!ViewModel.IsBusy) { instaNetworkLoader.ClearAnimation(); } ChangeSocialNetworkTextColor(); } }
/// <summary> /// Initializes a new instance of the <see cref="ViewModel"/> class. /// </summary> public ViewModel() { this.credentialStorage = new AppCredentialStorage(); var googleAuth = new GoogleAuthenticator(this.credentialStorage) { LogToConsole = this.Log }; var facebookAuth = new FacebookAuthenticator(this.credentialStorage) { LogToConsole = this.Log }; this.authenticationTypes = new List <AuthenticationType> { new AuthenticationType { Name = "None" }, new AuthenticationType { Name = facebookAuth.Name, Auth = facebookAuth, Identity = new FacebookIdentity { LogToConsole = this.Log } }, new AuthenticationType { Name = googleAuth.Name, Auth = googleAuth, Identity = new GoogleIdentity { LogToConsole = this.Log } } }; this.selectedType = this.authenticationTypes[0]; this.authenticationStatus = "Not Authenticated"; this.email = "N/A"; this.Log("Application initialized."); if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } this.Log("This is just a test message."); this.Log("To show the console when the display mode is set to design time enabled, and this is specifically a longer message to make it easier to test that text is wrapping appropriately."); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); _auth = new FacebookAuthenticator(Configuration.ClientId, Configuration.Scope, this); var facebookLoginButton = FindViewById <Button>(Resource.Id.facebookLoginButton); facebookLoginButton.Click += OnFacebookLoginButtonClicked; AppCenter.Start("f0e84c43-eb80-41fe-83af-b86ac30313e5", typeof(Analytics), typeof(Crashes)); }
public IHttpActionResult RegisterExternal(string state) { ApplicationUserLogin userLogin; state = state.ToLower(); if (state == "facebook") { var token = FacebookAuthenticator.RetrieveAccessToken(GetQueryString(this.Request, "code")); userLogin = FacebookAuthenticator.CreateUserLogin(token); } else if (state == "google") { var token = GoogleAuthenticator.RetrieveAccessToken(GetQueryString(this.Request, "code")); userLogin = GoogleAuthenticator.CreateUserLogin(token); } else if (state == "twitter") { var authToken = GetQueryString(this.Request, "oauth_token"); var authVerifier = GetQueryString(this.Request, "oauth_verifier"); userLogin = TwitterAuthenticator.CreateUserLogin(authToken, authVerifier); } else { return(this.BadRequest()); } var result = this._userRepo.CreateExternalUser(userLogin); var userToken = ApplicationUserManager.CreateToken(result.User); // Returns the user token in text/plain format to help our deficient friend IE var resp = this.Request.CreateResponse(); resp.Content = new StringContent(userToken, Encoding.UTF8, "text/plain"); if (result.UserCreated) { resp.StatusCode = HttpStatusCode.Created; return(this.ResponseMessage(resp)); } resp.StatusCode = HttpStatusCode.OK; return(this.ResponseMessage(resp)); }
public IConfigurable PrepareSubscription(MailboxSession mailbox, ConnectSubscriptionProxy proxy) { ArgumentValidator.ThrowIfNull("proxy", proxy); NewFacebookSubscription.Tracer.TraceFunction((long)this.GetHashCode(), "Entering NewFacebookSubscription.PrepareSubscription. Mailbox {0}.", new object[] { mailbox.Identity }); this.InitializeConfiguration(proxy.AppAuthorizationCode, proxy.RedirectUri); string text; string userId; if (NewFacebookSubscription.IsTestHook(proxy.AppAuthorizationCode)) { text = "***TEST_ACCESS_TOKEN***"; userId = "***TEST_USER_ID***"; } else { text = new FacebookAuthenticator(this.config).ExchangeAppAuthorizationCodeForAccessToken(proxy.AppAuthorizationCode); userId = NewFacebookSubscription.GetUserId(text); if (!CachedPeopleConnectApplicationConfig.Instance.ReadFacebook().SkipContactUpload) { NewFacebookSubscription.UploadContacts(mailbox, text); } else { NewFacebookSubscription.Tracer.TraceWarning <string>((long)this.GetHashCode(), "Skipping contact upload for new subscription in Mailbox {0}.", mailbox.Identity.ToString()); } } proxy.Subscription.SubscriptionType = AggregationSubscriptionType.Facebook; proxy.Subscription.SubscriptionProtocolName = ConnectSubscription.FacebookProtocolName; proxy.Subscription.SubscriptionProtocolVersion = ConnectSubscription.FacebookProtocolVersion; proxy.Subscription.SubscriptionEvents = SubscriptionEvents.WorkItemCompleted; proxy.SendAsCheckNeeded = false; proxy.ProviderGuid = ConnectSubscription.FacebookProviderGuid; proxy.MessageClass = "IPM.Aggregation.Facebook"; proxy.AssignAccessToken(text); proxy.AppId = this.config.AppId; proxy.UserId = userId; NewFacebookSubscription.Tracer.TraceFunction((long)this.GetHashCode(), "Leaving NewFacebookSubscription.PrepareSubscription. Mailbox {0}.", new object[] { mailbox.Identity }); return(proxy); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { this.ctlUserConsentForm.Visible = false; FacebookAuthenticatorConfig config = this.ReadConfiguration(); FacebookAuthenticator facebookAuthenticator = new FacebookAuthenticator(config); AppAuthorizationResponse response = FacebookAuthenticator.ParseAppAuthorizationResponse(base.Request.QueryString); if (!FacebookAuthenticator.IsRedirectFromFacebook(response)) { string text = facebookAuthenticator.GetAppAuthorizationUri().ToString(); if (this.IsReconnect()) { base.Response.Redirect(text); } else { this.ctlUserConsentForm.Visible = true; this.ctlUserConsentForm.AuthorizationUrl = text; } } else if (facebookAuthenticator.IsAuthorizationGranted(response)) { this.ProcessAuthorizationGranted(response); } else { this.ProcessAuthorizationDenied(); } } catch (ExchangeConfigurationException ex) { EcpEventLogConstants.Tuple_BadFacebookConfiguration.LogPeriodicEvent(EcpEventLogExtensions.GetPeriodicKeyPerUser(), new object[] { EcpEventLogExtensions.GetUserNameToLog(), ex }); ErrorHandlingUtil.TransferToErrorPage("badfacebookconfiguration"); } }
public void StampChangesOn(ConnectSubscriptionProxy proxy) { if (proxy == null) { throw new ArgumentNullException("proxy"); } this.InitializeConfiguration(proxy.RedirectUri); string text; string userId; if (SetFacebookSubscription.IsTestHook(proxy.AppAuthorizationCode)) { text = "***TEST_SET_ACCESS_TOKEN***"; userId = "***TEST_SET_USER_ID***"; } else { text = new FacebookAuthenticator(this.config).ExchangeAppAuthorizationCodeForAccessToken(proxy.AppAuthorizationCode); userId = SetFacebookSubscription.GetUserId(text); } proxy.AssignAccessToken(text); proxy.AppId = this.config.AppId; proxy.UserId = userId; }
public LoginForm() { InitializeComponent(); m_FacebookAuthenticator = new FacebookAuthenticator(); }