public void CheckSocialAccountAuthorizationStatus(NSString accountTypeIdentifier) { if (accountStore == null) { accountStore = new ACAccountStore(); } ACAccountType socialAccount = accountStore.FindAccountType(accountTypeIdentifier); DataClass dataClass; if (accountTypeIdentifier == ACAccountType.Facebook) { dataClass = DataClass.Facebook; } else if (accountTypeIdentifier == ACAccountType.Twitter) { dataClass = DataClass.Twitter; } else if (accountTypeIdentifier == ACAccountType.SinaWeibo) { dataClass = DataClass.SinaWeibo; } else { dataClass = DataClass.TencentWeibo; } ShowAlert(dataClass, socialAccount.AccessGranted ? "granted" : "denied"); }
ACAccountStore accountStore; // Save this reference since ACAccounts are only good so long as it's alive public override Task <IEnumerable <Account> > GetAccountsAsync() { if (accountStore == null) { accountStore = new ACAccountStore(); } var store = new ACAccountStore(); var at = store.FindAccountType(ACAccountType.Twitter); var tcs = new TaskCompletionSource <IEnumerable <Account> > (); store.RequestAccess(at, (granted, error) => { if (granted) { var accounts = store.FindAccounts(at) .Select(a => (Account) new ACAccountWrapper(a, store)) .ToList(); tcs.SetResult(accounts); } else { tcs.SetResult(new Account [0]); } }); return(tcs.Task); }
public void TestFacebookAuth() { var sg = new SyncGateway("http", GetReplicationServer()); using (var remoteDb = sg.CreateDatabase("facebook")) { remoteDb.DisableGuestAccess(); var doneEvent = new ManualResetEvent(false); var accountStore = new ACAccountStore(); var accountType = accountStore.FindAccountType(ACAccountType.Facebook); var options = new AccountStoreOptions(); options.FacebookAppId = FacebookAppId; options.SetPermissions(ACFacebookAudience.Friends, new [] { "email" }); var success = true; ACAccount account = null; accountStore.RequestAccess(accountType, options, (result, error) => { success = result; if (success) { var accounts = accountStore.FindAccounts(accountType); account = accounts != null && accounts.Length > 0 ? accounts[0] : null; } else { Log.W(Tag, "Facebook Login needed. Go to Settings > Facebook and login."); Log.E(Tag, "Facebook Request Access Error : " + error); } doneEvent.Set(); }); doneEvent.WaitOne(TimeSpan.FromSeconds(30)); Assert.IsTrue(success); Assert.IsNotNull(account); var token = account.Credential.OAuthToken; Assert.IsNotNull(token); Assert.IsTrue(token.Length > 0); var url = remoteDb.RemoteUri; Replication replicator = database.CreatePushReplication(url); replicator.Authenticator = AuthenticatorFactory.CreateFacebookAuthenticator(token); Assert.IsNotNull(replicator); Assert.IsNotNull(replicator.Authenticator); Assert.IsTrue(replicator.Authenticator is TokenAuthenticator); CreateDocuments(database, 20); RunReplication(replicator); var urlStr = url.ToString(); urlStr = urlStr.EndsWith("/") ? urlStr : urlStr + "/"; //var cookies = httpClientFactory.GetCookieContainer().GetCookies(new Uri(urlStr)); //Assert.IsTrue(cookies.Count == 1); //Assert.AreEqual("SyncGatewaySession", cookies[0].Name); } }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); // Update UI based on state SendTweet.Enabled = isTwitterAvailable; RequestTwitterTimeline.Enabled = false; PostToFacebook.Enabled = isFacebookAvailable; RequestFacebookTimeline.Enabled = false; // Initialize Twitter Account access var accountStore = new ACAccountStore(); var accountType = accountStore.FindAccountType(ACAccountType.Twitter); // Request access to Twitter account accountStore.RequestAccess(accountType, null, (granted, error) => { // Allowed by user? if (granted) { // Get account if (accountStore.Accounts.Length == 0) { return; } twitterAccount = accountStore.Accounts [accountStore.Accounts.Length - 1]; InvokeOnMainThread(() => { // Update UI RequestTwitterTimeline.Enabled = true; }); } }); // Initialize facebook Account access var options = new AccountStoreOptions(); options.FacebookAppId = ""; // Enter your specific Facebook App ID here accountType = accountStore.FindAccountType(ACAccountType.Facebook); // Request access to Facebook account accountStore.RequestAccess(accountType, options, (granted, error) => { // Allowed by user? if (granted) { if (accountStore.Accounts.Length == 0) { return; } // Get account facebookAccount = accountStore.Accounts [accountStore.Accounts.Length - 1]; InvokeOnMainThread(() => { // Update UI RequestFacebookTimeline.Enabled = true; }); } }); }
public ACAccountWrapper (ACAccount account, ACAccountStore store) { if (account == null) { throw new ArgumentNullException ("account"); } this.ACAccount = account; this.store = store; }
private Tuple <string, string> verifyFacebookFromSerttings() { Tuple <string, string> signedInResult = Tuple.Create <string, string>(string.Empty, string.Empty); AutoResetEvent taskCompleted = new AutoResetEvent(false); var options = new AccountStoreOptions() { FacebookAppId = "1626108114272416" }; options.SetPermissions(ACFacebookAudience.Friends, new[] { "public_profile", "email" }); ACAccountStore accountStore = new ACAccountStore(); var accountType = accountStore.FindAccountType(ACAccountType.Facebook); var facebookAccounts = accountStore.FindAccounts(accountType); if ((facebookAccounts == null) || (facebookAccounts.Length == 0)) { accountStore.RequestAccess(accountType, options, (granted, error2) => { if (granted) { facebookAccounts = accountStore.FindAccounts(accountType); } taskCompleted.Set(); }); taskCompleted.WaitOne(); } if ((facebookAccounts != null) && (facebookAccounts.Length > 0)) { var facebookAccount = facebookAccounts[0]; accountStore.RenewCredentials(facebookAccount, (result, error1) => { if (result == ACAccountCredentialRenewResult.Renewed) { var id = parseFacebookUserIdFromSettings(facebookAccount); if (!string.IsNullOrEmpty(id)) { signedInResult = Tuple.Create <string, string>(facebookAccount.Credential.OAuthToken, id); } } taskCompleted.Set(); }); } else { taskCompleted.Set(); } taskCompleted.WaitOne(); return(signedInResult); }
public ACAccountWrapper (ACAccount account, ACAccountStore store) { if (account == null) { throw new ArgumentNullException ("account"); } this.ACAccount = account; this.store = store; this.isTwitterAccount = account.AccountType.Identifier == store.FindAccountType (ACAccountType.Twitter).Identifier; }
public ACAccountWrapper(ACAccount account, ACAccountStore store) { if (account == null) { throw new ArgumentNullException("account"); } this.ACAccount = account; this.store = store; }
public ACAccountWrapper(ACAccount account, ACAccountStore store) { if (account == null) { throw new ArgumentNullException("account"); } this.ACAccount = account; this.store = store; this.isTwitterAccount = account.AccountType.Identifier == store.FindAccountType(ACAccountType.Twitter).Identifier; }
public override void ViewWillAppear (bool animated) { base.ViewWillAppear (animated); // Update UI based on state SendTweet.Enabled = isTwitterAvailable; RequestTwitterTimeline.Enabled = false; PostToFacebook.Enabled = isFacebookAvailable; RequestFacebookTimeline.Enabled = false; // Initialize Twitter Account access var accountStore = new ACAccountStore (); var accountType = accountStore.FindAccountType (ACAccountType.Twitter); // Request access to Twitter account accountStore.RequestAccess (accountType, null, (granted, error) => { // Allowed by user? if (granted) { // Get account if (accountStore.Accounts.Length == 0) return; twitterAccount = accountStore.Accounts [accountStore.Accounts.Length - 1]; InvokeOnMainThread (() => { // Update UI RequestTwitterTimeline.Enabled = true; }); } }); // Initialize facebook Account access var options = new AccountStoreOptions (); options.FacebookAppId = ""; // Enter your specific Facebook App ID here accountType = accountStore.FindAccountType (ACAccountType.Facebook); // Request access to Facebook account accountStore.RequestAccess (accountType, options, (granted, error) => { // Allowed by user? if (granted) { if (accountStore.Accounts.Length == 0) return; // Get account facebookAccount = accountStore.Accounts [accountStore.Accounts.Length - 1]; InvokeOnMainThread (() => { // Update UI RequestFacebookTimeline.Enabled = true; }); } }); }
public void RequestSinaWeiboAccess() { if (accountStore == null) { accountStore = new ACAccountStore(); } ACAccountType sinaWeiboAccount = accountStore.FindAccountType(ACAccountType.SinaWeibo); accountStore.RequestAccess(sinaWeiboAccount, null, delegate(bool granted, NSError error) { ShowAlert(DataClass.SinaWeibo, granted ? "granted" : "denied"); }); }
public void RequestTwitterAccess() { if (accountStore == null) { accountStore = new ACAccountStore(); } ACAccountType twitterAccount = accountStore.FindAccountType(ACAccountType.Twitter); accountStore.RequestAccess(twitterAccount, null, delegate(bool granted, NSError error) { ShowAlert(DataClass.Twitter, granted ? "granted" : "denied"); }); }
private void HandleTwitterAuth(object sender, EventArgs args) { if (HardwareDetection.RunningiOS5OrHigher) { //if we are running iOS5 or later, we can use the in-built API for handling twitter authentication. accountStore = new ACAccountStore(); accountStore.RequestAccess(accountStore.FindAccountType(ACAccountType.Twitter), retrievedAccounts); } else { HandleTwitterOAuth(); } }
public void Manual_HasMultipleAccounts () { var store = new ACAccountStore (); var at = store.FindAccountType (ACAccountType.Twitter); store.RequestAccess (at, (granted, error) => { if (granted) { var accounts = store.FindAccounts (at); Assert.That (accounts.Length, Is.GreaterThanOrEqualTo (2)); } }); }
public void Manual_HasMultipleAccounts() { var store = new ACAccountStore(); var at = store.FindAccountType(ACAccountType.Twitter); store.RequestAccess(at, (granted, error) => { if (granted) { var accounts = store.FindAccounts(at); Assert.That(accounts.Length, Is.GreaterThanOrEqualTo(2)); } }); }
async Task <bool> LoginTwitterOld() { #if __IOS__ var store = new ACAccountStore(); var accountType = store.FindAccountType(ACAccountType.Twitter); var success = false; var result = await store.RequestAccessAsync(accountType); success = result.Item1; if (!success) { Settings.TwitterEnabled = false; return(false); } var accounts = store.FindAccounts(accountType); if ((accounts?.Length ?? 0) == 0) { Settings.TwitterEnabled = false; return(false); } if (accounts?.Length == 1) { Settings.TwitterEnabled = true; var a = accounts[0]; Settings.TwitterAccount = a.Identifier; Settings.TwitterDisplay = a.UserFullName; return(true); } var sheet = new MusicPlayer.iOS.Controls.ActionSheet("Twitter"); var sheetTask = new TaskCompletionSource <bool>(); foreach (var a in accounts) { sheet.Add(a.Identifier, () => { Settings.TwitterEnabled = true; Settings.TwitterAccount = a.Identifier; Settings.TwitterDisplay = a.UserFullName; sheetTask.TrySetResult(true); }); } sheet.Add(Strings.Nevermind, null, true); sheet.Show(AppDelegate.window.RootViewController, AppDelegate.window.RootViewController.View); #endif return(false); }
public static void getAccount() { if (twitterAccount != null) return; ACAccountStore accountStore = new ACAccountStore(); ACAccountType accountTypeTwitter = accountStore.FindAccountType(ACAccountType.Twitter); accountStore.RequestAccess(accountTypeTwitter, (granted, error) => { if (!granted) return; ACAccount[] accounts = accountStore.FindAccounts(accountTypeTwitter); if (accounts.Length > 0) twitterAccount = accounts[0]; }); }
public void RequestTencentWeiboAccess() { if (accountStore == null) { accountStore = new ACAccountStore(); } ACAccountType tencentWeiboAccount = accountStore.FindAccountType(ACAccountType.TencentWeibo); AccountStoreOptions options = new AccountStoreOptions(); options.TencentWeiboAppId = "MY_ID"; accountStore.RequestAccess(tencentWeiboAccount, options, delegate(bool granted, NSError error) { ShowAlert(DataClass.TencentWeibo, granted ? "granted" : "denied"); }); }
public static Task <ACAccountCredentialRenewResult> RenewCredentialsAsync(this ACAccountStore store, ACAccount account) { TaskCompletionSource <ACAccountCredentialRenewResult> tcs = new TaskCompletionSource <ACAccountCredentialRenewResult> (); store.RenewCredentials(account, delegate(ACAccountCredentialRenewResult arg1, NSError arg2) { if (arg2 != null) { tcs.SetException(new NSErrorException(arg2)); } else { tcs.SetResult(arg1); } }); return(tcs.Task); }
public static Task <bool> RequestAccessAsync(this ACAccountStore store, ACAccountType accountType, AccountStoreOptions options) { TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool> (); store.RequestAccess(accountType, options, delegate(bool granted, NSError error) { if (error != null) { tcs.SetException(new NSErrorException(error)); } else { tcs.SetResult(granted); } }); return(tcs.Task); }
private void handleManualAuth() { if (accountStore != null) { accountStore.Dispose(); accountStore = null; } Notification n = new Notification(LocalisationManager.GetString(OsuString.AccessNotGranted), LocalisationManager.GetString(OsuString.AccessNotGrantedDetails), NotificationStyle.YesNo, delegate(bool resp) { if (resp) { HandleTwitterOAuth(); } }); GameBase.Notify(n); }
public void RequestFacebookAccess() { if (accountStore == null) { accountStore = new ACAccountStore(); } ACAccountType facebookAccount = accountStore.FindAccountType(ACAccountType.Facebook); AccountStoreOptions options = new AccountStoreOptions() { FacebookAppId = "MY_CODE" }; options.SetPermissions(ACFacebookAudience.Friends, new [] { "email", "user_about_me" }); accountStore.RequestAccess(facebookAccount, options, delegate(bool granted, NSError error) { ShowAlert(DataClass.Facebook, granted ? "granted" : "denied"); }); }
async Task <bool> SubmitScrobbleToTwitter(Song song) { try { #if __IOS__ var store = new ACAccountStore(); //var accountType = store.FindAccountType(ACAccountType.Twitter); var account = store.FindAccount(Settings.TwitterAccount); var message = $"#NowPlaying {song.ToString(114)} on @gMusicApp"; var request = new TWRequest(new NSUrl("https://api.twitter.com/1.1/statuses/update.json"), NSDictionary.FromObjectAndKey((NSString)message, (NSString)"status"), TWRequestMethod.Post); request.Account = account; var result = await request.PerformRequestAsync(); #endif return(true); } catch (Exception ex) { LogManager.Shared.Report(ex); return(false); } }
async Task <bool> SubmitScrobbleToTwitter(Song song) { var message = $"#NowPlaying {song.ToString(254)} on @gMusicApp"; try { if (!Device.HasIntegratedTwitter) { var resp = await twitter.Post(null, "statuses/update.json", new Dictionary <string, string> { ["status"] = message }); Console.WriteLine(resp); } else { #if __IOS__ var store = new ACAccountStore(); //var accountType = store.FindAccountType(ACAccountType.Twitter); var account = store.FindAccount(Settings.TwitterAccount); var request = new TWRequest(new NSUrl("https://api.twitter.com/1.1/statuses/update.json"), NSDictionary.FromObjectAndKey((NSString)message, (NSString)"status"), TWRequestMethod.Post); request.Account = account; var result = await request.PerformRequestAsync(); #endif } return(true); } catch (Exception ex) { LogManager.Shared.Report(ex); return(false); } }
public SocialNetworkPrivacyManager(NSString socialNetworkName) { socialNetwork = socialNetworkName; accountStore = new ACAccountStore(); }
ACAccountStore accountStore; // Save this reference since ACAccounts are only good so long as it's alive public override Task<IEnumerable<Account>> GetAccountsAsync () { if (accountStore == null) { accountStore = new ACAccountStore (); } var store = new ACAccountStore (); var at = store.FindAccountType (ACAccountType.Twitter); var tcs = new TaskCompletionSource<IEnumerable<Account>> (); store.RequestAccess (at, (granted, error) => { if (granted) { var accounts = store.FindAccounts (at) .Select (a => (Account) new ACAccountWrapper (a, store)) .ToList (); tcs.SetResult (accounts); } else { tcs.SetResult (new Account [0]); } }); return tcs.Task; }
/// <summary> U3DXT internal. </summary> protected DirectRequestService(string accountType, string serviceType) { _service = new ACAccountStore(); _accountType = _service.FindAccountType(accountType); _serviceType = serviceType; }
public SocialNetworkPrivacyManager(NSString socialNetworkName) { socialNetwork = socialNetworkName; accountStore = new ACAccountStore (); }
public async Task<IEnumerable<Account>> GetTwitterHandleAsync() { var store = new ACAccountStore(); var accountType = store.FindAccountType(ACAccountType.Twitter); var allowed = await store.RequestAccessAsync(accountType, null); return !allowed.Item1 ? null : store.FindAccounts(accountType).Select(CreateTwitterUser).ToList(); }
public SettingViewController() : base(UITableViewStyle.Plain, null) { Title = Strings.Settings; accountsSection = new MenuSection("Accounts") { (addNewAccountElement = new SettingsElement("Add Streaming Service", async() => { try{ var vc = new ServicePickerViewController(); this.PresentModalViewController(new UINavigationController(vc), true); var service = await vc.GetServiceTypeAsync(); await ApiManager.Shared.CreateAndLogin(service); UpdateAccounts(); } catch (TaskCanceledException) { } catch (Exception ex) { Console.WriteLine(ex); } })), (lastFmElement = string.IsNullOrEmpty(ApiConstants.LastFmApiKey) ? null : new SettingsSwitch("Last.FM", Settings.LastFmEnabled)), (twitterScrobbleElement = new SettingsSwitch("Auto Tweet", Settings.TwitterEnabled) { Detail = Settings.TwitterDisplay }), new SettingsSwitch("Import iPod Music", Settings.IncludeIpod) { ValueUpdated = ToggleIPod }, new MenuHelpTextElement( "Automatically imports and plays music from your local library. This saves data and space on your phone."), }; Root = new RootElement(Strings.Settings) { accountsSection, new MenuSection(Strings.Playback) { new SettingsSwitch(Strings.EnableLikeOnTheLockScreen, Settings.ThubsUpOnLockScreen) { ValueUpdated = (b => { Settings.ThubsUpOnLockScreen = b; RemoteControlHandler.SetupThumbsUp(); }) }, new MenuHelpTextElement(Strings.EnableLikeHint), new SettingsSwitch(Strings.EnableGaplessPlayback, Settings.ThubsUpOnLockScreen) { ValueUpdated = (b => { Settings.ThubsUpOnLockScreen = b; RemoteControlHandler.SetupThumbsUp(); }) }, new MenuHelpTextElement(Strings.EnableGapplessHint), new SettingsSwitch(Strings.PlayVideosWhenAvailable, Settings.PreferVideos) { ValueUpdated = (b => { Settings.PreferVideos = b; }) }, new MenuHelpTextElement(Strings.PlaysMusicVideoHint), new SettingsSwitch(Strings.PlayCleanVersionsOfSongs, Settings.FilterExplicit) { ValueUpdated = (b => { Settings.FilterExplicit = b; }) }, new MenuHelpTextElement(Strings.PlayesCleanVersionOfSongsHint), }, new MenuSection(Strings.Streaming) { new SettingsSwitch(Strings.DisableAllAccess, Settings.DisableAllAccess) { ValueUpdated = (on) => { Settings.DisableAllAccess = on; } }, new MenuHelpTextElement(Strings.DisableAllAccessHint), (CreateQualityPicker(Strings.CellularAudioQuality, Settings.MobileStreamQuality, (q) => Settings.MobileStreamQuality = q)), (CreateQualityPicker(Strings.WifiAudioQuality, Settings.WifiStreamQuality, (q) => Settings.WifiStreamQuality = q)), (CreateQualityPicker(Strings.VideoQuality, Settings.VideoStreamQuality, (q) => Settings.VideoStreamQuality = q)), (CreateQualityPicker(Strings.OfflineAudioQuality, Settings.DownloadStreamQuality, (q) => Settings.DownloadStreamQuality = q)), new MenuHelpTextElement(Strings.QualityHints) }, new MenuSection(Strings.Feedback) { new SettingsElement(Strings.SendFeedback, SendFeedback) { TextColor = iOS.Style.DefaultStyle.MainTextColor }, new SettingsElement($"{Strings.PleaseRate} {AppDelegate.AppName}", RateAppStore) { TextColor = iOS.Style.DefaultStyle.MainTextColor }, (ratingMessage = new MenuHelpTextElement(Strings.NobodyHasRatedYet)) }, new MenuSection(Strings.Settings) { CreateThemePicker("Theme"), new SettingsElement(Strings.ResyncDatabase, () => { Settings.ResetApiModes(); ApiManager.Shared.ReSync(); }), new MenuHelpTextElement(Strings.ResyncDatabaseHint), new SettingsElement(Strings.DownloadQueue, () => NavigationController.PushViewController(new DownloadViewController(), true)), (songsElement = new SettingsElement(Strings.SongsCount)) } }; if (lastFmElement != null) { lastFmElement.ValueUpdated = async b => { if (!b) { Settings.LastFmEnabled = false; ScrobbleManager.Shared.LogOut(); return; } var success = false; try { success = await ScrobbleManager.Shared.LoginToLastFm(); } catch (TaskCanceledException ex) { lastFmElement.Value = Settings.LastFmEnabled = false; TableView.ReloadData(); return; } Settings.LastFmEnabled = success; if (success) { return; } lastFmElement.Value = false; ReloadData(); App.ShowAlert($"{Strings.ErrorLoggingInto} Last.FM", Strings.PleaseTryAgain); }; } twitterScrobbleElement.ValueUpdated = async b => { if (!b) { Settings.TwitterEnabled = false; Settings.TwitterDisplay = ""; Settings.TwitterAccount = ""; twitterScrobbleElement.Detail = ""; return; } var store = new ACAccountStore(); var accountType = store.FindAccountType(ACAccountType.Twitter); var success = false; var result = await store.RequestAccessAsync(accountType); success = result.Item1; if (!success) { Settings.TwitterEnabled = false; twitterScrobbleElement.Value = false; ReloadData(); return; } var accounts = store.FindAccounts(accountType); if ((accounts?.Length ?? 0) == 0) { Settings.TwitterEnabled = false; twitterScrobbleElement.Value = false; ReloadData(); return; } if (accounts?.Length == 1) { Settings.TwitterEnabled = true; var a = accounts[0]; Settings.TwitterAccount = a.Identifier; twitterScrobbleElement.Detail = Settings.TwitterDisplay = a.UserFullName; ReloadData(); return; } var sheet = new ActionSheet("Twitter"); foreach (var a in accounts) { sheet.Add(a.Identifier, () => { Settings.TwitterEnabled = true; Settings.TwitterAccount = a.Identifier; twitterScrobbleElement.Detail = Settings.TwitterDisplay = a.UserFullName; ReloadData(); }); } sheet.Add(Strings.Nevermind, null, true); sheet.Show(this, TableView); }; }
public void TestFacebookAuth() { var sg = new SyncGateway("http", GetReplicationServer()); using (var remoteDb = sg.CreateDatabase("facebook")) { remoteDb.DisableGuestAccess(); var doneEvent = new ManualResetEvent(false); var accountStore = new ACAccountStore(); var accountType = accountStore.FindAccountType(ACAccountType.Facebook); var options = new AccountStoreOptions(); options.FacebookAppId = FacebookAppId; options.SetPermissions(ACFacebookAudience.Friends, new [] { "email" }); var success = true; ACAccount account = null; accountStore.RequestAccess(accountType, options, (result, error) => { success = result; if (success) { var accounts = accountStore.FindAccounts(accountType); account = accounts != null && accounts.Length > 0 ? accounts[0] : null; } else { Log.W(Tag, "Facebook Login needed. Go to Settings > Facebook and login."); Log.E(Tag, "Facebook Request Access Error : " + error); } doneEvent.Set(); }); doneEvent.WaitOne(TimeSpan.FromSeconds(30)); Assert.IsTrue(success); Assert.IsNotNull(account); var token = account.Credential.OAuthToken; Assert.IsNotNull(token); Assert.IsTrue(token.Length > 0); var url = remoteDb.RemoteUri; var cookieStore = new CookieStore(manager.Directory); var httpClientFactory = new CouchbaseLiteHttpClientFactory(cookieStore); manager.DefaultHttpClientFactory = httpClientFactory; Replication replicator = database.CreatePushReplication(url); replicator.Authenticator = AuthenticatorFactory.CreateFacebookAuthenticator(token); Assert.IsNotNull(replicator); Assert.IsNotNull(replicator.Authenticator); Assert.IsTrue(replicator.Authenticator is TokenAuthenticator); CreateDocuments(database, 20); RunReplication(replicator); var urlStr = url.ToString(); urlStr = urlStr.EndsWith("/") ? urlStr : urlStr + "/"; //var cookies = httpClientFactory.GetCookieContainer().GetCookies(new Uri(urlStr)); //Assert.IsTrue(cookies.Count == 1); //Assert.AreEqual("SyncGatewaySession", cookies[0].Name); } }
public void RequestTencentWeiboAccess () { if (accountStore == null) accountStore = new ACAccountStore (); ACAccountType tencentWeiboAccount = accountStore.FindAccountType (ACAccountType.TencentWeibo); AccountStoreOptions options = new AccountStoreOptions (); options.TencentWeiboAppId = "MY_ID"; accountStore.RequestAccess (tencentWeiboAccount, options, delegate (bool granted, NSError error) { ShowAlert (DataClass.TencentWeibo, granted ? "granted" : "denied"); }); }
public void RequestSinaWeiboAccess () { if (accountStore == null) accountStore = new ACAccountStore (); ACAccountType sinaWeiboAccount = accountStore.FindAccountType (ACAccountType.SinaWeibo); accountStore.RequestAccess (sinaWeiboAccount, null, delegate(bool granted, NSError error) { ShowAlert (DataClass.SinaWeibo, granted ? "granted" : "denied"); }); }
public void RequestTwitterAccess () { if (accountStore == null) accountStore = new ACAccountStore (); ACAccountType twitterAccount = accountStore.FindAccountType (ACAccountType.Twitter); accountStore.RequestAccess (twitterAccount, null, delegate (bool granted, NSError error) { ShowAlert (DataClass.Twitter, granted ? "granted" : "denied"); }); }
private TwitterApi() { accountStore = new ACAccountStore(); loadingAccount = LoadAccountAsync(); }
public void TestFacebookAuth() { var doneEvent = new ManualResetEvent(false); var accountStore = new ACAccountStore(); var accountType = accountStore.FindAccountType(ACAccountType.Facebook); var options = new AccountStoreOptions(); options.FacebookAppId = FacebookAppId; options.SetPermissions(ACFacebookAudience.Friends, new [] { "email" }); var success = true; ACAccount account = null; accountStore.RequestAccess(accountType, options, (result, error) => { success = result; if (success) { var accounts = accountStore.FindAccounts(accountType); account = accounts != null && accounts.Length > 0 ? accounts[0] : null; } else { Log.W(Tag, "Facebook Login needed. Go to Settings > Facebook and login."); Log.E(Tag, "Facebook Request Access Error : " + error); } doneEvent.Set(); }); doneEvent.WaitOne(TimeSpan.FromSeconds(30)); Assert.IsTrue(success); Assert.IsNotNull(account); var token = account.Credential.OAuthToken; Assert.IsNotNull(token); Assert.IsTrue(token.Length > 0); var url = GetReplicationURLWithoutCredentials(); var cookieStore = new CookieStore(); var httpClientFactory = new CouchbaseLiteHttpClientFactory(cookieStore); manager.DefaultHttpClientFactory = httpClientFactory; Replication replicator = database.CreatePushReplication(url); replicator.Authenticator = AuthenticatorFactory.CreateFacebookAuthenticator(token); Assert.IsNotNull(replicator); Assert.IsNotNull(replicator.Authenticator); Assert.IsTrue(replicator.Authenticator is TokenAuthenticator); replicator.Start(); doneEvent.Reset(); Task.Factory.StartNew(() => { var timeout = DateTime.UtcNow + TimeSpan.FromSeconds(30); while (DateTime.UtcNow < timeout) { if (!replicator.active) { break; } System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(10)); } doneEvent.Set(); }); doneEvent.WaitOne(TimeSpan.FromSeconds(35)); var urlStr = url.ToString(); urlStr = urlStr.EndsWith("/") ? urlStr : urlStr + "/"; var cookies = httpClientFactory.GetCookieContainer().GetCookies(new Uri(urlStr)); Assert.IsTrue(cookies.Count == 1); Assert.AreEqual("SyncGatewaySession", cookies[0].Name); }
public void CheckSocialAccountAuthorizationStatus (NSString accountTypeIdentifier) { if (accountStore == null) accountStore = new ACAccountStore (); ACAccountType socialAccount = accountStore.FindAccountType (accountTypeIdentifier); DataClass dataClass; if (accountTypeIdentifier == ACAccountType.Facebook) dataClass = DataClass.Facebook; else if (accountTypeIdentifier == ACAccountType.Twitter) dataClass = DataClass.Twitter; else if (accountTypeIdentifier == ACAccountType.SinaWeibo) dataClass = DataClass.SinaWeibo; else dataClass = DataClass.TencentWeibo; ShowAlert (dataClass, socialAccount.AccessGranted ? "granted" : "denied"); }
public void RequestFacebookAccess () { if (accountStore == null) accountStore = new ACAccountStore (); ACAccountType facebookAccount = accountStore.FindAccountType (ACAccountType.Facebook); AccountStoreOptions options = new AccountStoreOptions () { FacebookAppId = "MY_CODE" }; options.SetPermissions (ACFacebookAudience.Friends, new [] { "email", "user_about_me" }); accountStore.RequestAccess (facebookAccount, options, delegate (bool granted, NSError error) { ShowAlert (DataClass.Facebook, granted ? "granted" : "denied"); }); }
public void TestFacebookAuth() { var doneEvent = new ManualResetEvent(false); var accountStore = new ACAccountStore(); var accountType = accountStore.FindAccountType(ACAccountType.Facebook); var options = new AccountStoreOptions(); options.FacebookAppId = FacebookAppId; options.SetPermissions(ACFacebookAudience.Friends, new [] { "email" }); var success = true; ACAccount account = null; accountStore.RequestAccess(accountType, options, (result, error) => { success = result; if (success) { var accounts = accountStore.FindAccounts(accountType); account = accounts != null && accounts.Length > 0 ? accounts[0] : null; } else { Log.W(Tag, "Facebook Login needed. Go to Settings > Facebook and login."); Log.E(Tag, "Facebook Request Access Error : " + error); } doneEvent.Set(); }); doneEvent.WaitOne(TimeSpan.FromSeconds(30)); Assert.IsTrue(success); Assert.IsNotNull(account); var token = account.Credential.OAuthToken; Assert.IsNotNull(token); Assert.IsTrue(token.Length > 0); var url = GetReplicationURLWithoutCredentials(); var cookieStore = new CookieStore(); var httpClientFactory = new CouchbaseLiteHttpClientFactory(cookieStore); manager.DefaultHttpClientFactory = httpClientFactory; Replication replicator = database.CreatePushReplication(url); replicator.Authenticator = AuthenticatorFactory.CreateFacebookAuthenticator(token); Assert.IsNotNull(replicator); Assert.IsNotNull(replicator.Authenticator); Assert.IsTrue(replicator.Authenticator is TokenAuthenticator); replicator.Start(); doneEvent.Reset(); Task.Factory.StartNew(()=> { var timeout = DateTime.UtcNow + TimeSpan.FromSeconds(30); while (DateTime.UtcNow < timeout) { if (!replicator.active) { break; } System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(10)); } doneEvent.Set(); }); doneEvent.WaitOne(TimeSpan.FromSeconds(35)); var urlStr = url.ToString(); urlStr = urlStr.EndsWith("/") ? urlStr : urlStr + "/"; var cookies = httpClientFactory.GetCookieContainer().GetCookies(new Uri(urlStr)); Assert.IsTrue(cookies.Count == 1); Assert.AreEqual("SyncGatewaySession", cookies[0].Name); }
private void doSubmission() { int deviceType = 0; #if iOS if (!GameBase.Mapper) { deviceType = (int)osum.Support.iPhone.HardwareDetection.Version; //todo: for iOS5 twitter authentication, we need to double-check we actually have auth. string hash = GameBase.Config.GetValue <string>("hash", null); if (hash == null) { //todo: no twitter auth. are we not submitting anymore? return; } else if (hash.StartsWith("ios-")) { hash = hash.Substring(4); using (ACAccountStore store = new ACAccountStore()) { ACAccount account = store.FindAccount(hash); if (account != null) { //yay, i think. //todo: test that this actually checks grants (it should in theory). } else { GameBase.Notify("Twitter authentication failed. Please visit the options screen to login again."); GameBase.Config.SetValue <string>("username", null); GameBase.Config.SetValue <string>("hash", null); GameBase.Config.SetValue <string>("twitterId", null); GameBase.Config.SaveConfig(); return; } } } string check = CryptoHelper.GetMd5String("moocow" + GameBase.Instance.DeviceIdentifier + RankableScore.count100 + RankableScore.count300 + RankableScore.count50 + RankableScore.countMiss + RankableScore.maxCombo + RankableScore.spinnerBonusScore + RankableScore.comboBonusScore + RankableScore.accuracyBonusScore + RankableScore.Ranking + Path.GetFileName(Player.Beatmap.ContainerFilename) + deviceType + RankableScore.hitScore + (int)Player.Difficulty); string postString = "udid=" + GameBase.Instance.DeviceIdentifier + "&count300=" + RankableScore.count300 + "&count100=" + RankableScore.count100 + "&count50=" + RankableScore.count50 + "&countMiss=" + RankableScore.countMiss + "&maxCombo=" + RankableScore.maxCombo + "&spinnerBonus=" + RankableScore.spinnerBonusScore + "&comboBonus=" + RankableScore.comboBonusScore + "&accuracyBonus=" + RankableScore.accuracyBonusScore + "&hitScore=" + RankableScore.hitScore + "&rank=" + RankableScore.Ranking + "&filename=" + NetRequest.UrlEncode(Path.GetFileName(Player.Beatmap.ContainerFilename)) + "&cc=" + GameBase.Config.GetValue <string>("hash", string.Empty) + "&c=" + check + "&difficulty=" + (int)Player.Difficulty + "&username="******"username", string.Empty) + "&twitterid=" + GameBase.Config.GetValue <string>("twitterId", string.Empty) + "&dt=" + deviceType + "&offset=" + avg; spriteSubmitting = new pSprite(TextureManager.Load(OsuTexture.songselect_audio_preview), FieldTypes.StandardSnapRight, OriginTypes.Centre, ClockTypes.Game, new Vector2(20, 20), 0.999f, true, Color4.White) { ExactCoordinates = false, DimImmune = true, ScaleScalar = 0.7f }; spriteSubmitting.Transform(new TransformationF(TransformationType.Rotation, 0, MathHelper.Pi * 2, Clock.Time, Clock.Time + 1500) { Looping = true }); GameBase.MainSpriteManager.Add(spriteSubmitting); spriteSubmitting.FadeInFromZero(300); StringNetRequest nr = new StringNetRequest("https://www.osustream.com/score/submit.php", "POST", postString); nr.onFinish += delegate(string result, Exception e) { spriteSubmitting.AlwaysDraw = false; if (e == null) { spriteSubmitting.FadeOut(200); spriteSubmitting.ScaleTo(3, 200); spriteSubmitting.Colour = Color4.YellowGreen; } else { spriteSubmitting.FadeOut(1000); spriteSubmitting.ScaleTo(1.2f, 200, EasingTypes.In); spriteSubmitting.Colour = Color4.Red; } if (e == null && result != null && result.StartsWith("message:")) { rankingNotification = new Notification("Ranking", result.Replace("message:", string.Empty), NotificationStyle.Okay); if (finishedDisplaying) { GameBase.Notify(rankingNotification); } } }; NetManager.AddRequest(nr); } #endif }