public void LoginToSymplifiedToken() { SymplifiedAuthenticator authenticator = new SymplifiedAuthenticator( new Uri("https://idp.symplified.net"), new Uri("https://idp.symplified.net/portal/mobile/applications.html") ); authenticator.Completed += (s, e) => { loginViewController.DismissViewController(true, null); if (!e.IsAuthenticated) { tokenLoginStatusStringElement.Caption = "Not authorized"; } else { tokenLoginStatusStringElement.Caption = "Authorized"; tokenLoginStatusStringElement.GetActiveCell().BackgroundColor = UIColor.Green; } loginViewController.ReloadData(); }; vc = authenticator.GetUI(); loginViewController.PresentViewController(vc, true, null); }
private void Share(Service service, StringElement button) { Item item = new Item { Text = "I'm sharing great things using Xamarin!", Links = new List <Uri> { new Uri("http://xamarin.com"), }, }; UIViewController vc = service.GetShareUI(item, shareResult => { dialog.DismissViewController(true, null); button.GetActiveCell().TextLabel.Text = service.Title + " shared: " + shareResult; }); dialog.PresentViewController(vc, true, null); }
public void PerformSalesforceOAuthSaml2Grant() { XmlDocument xDoc = new XmlDocument(); xDoc.PreserveWhitespace = true; xDoc.Load("salesforce-oauthsaml2-idp-metadata.xml"); Saml20MetadataDocument idpMetadata = new Saml20MetadataDocument(xDoc); Saml20Authenticator authenticator = new Saml20Authenticator( "Symplified.Auth.iOS.Sample", idpMetadata ); authenticator.Completed += (s, e) => { loginViewController.DismissViewController(true, null); if (!e.IsAuthenticated) { samlLoginStatusStringElement.Caption = "Not authorized"; samlLoginStatusStringElement.GetActiveCell().BackgroundColor = UIColor.Red; } else { SamlAccount authenticatedAccount = (SamlAccount)e.Account; samlLoginStatusStringElement.Caption = authenticatedAccount.Assertion.Subject.Value; samlLoginStatusStringElement.GetActiveCell().BackgroundColor = UIColor.Green; authenticatedAccount.GetBearerAssertionAuthorizationGrant( new Uri("https://login.salesforce.com/services/oauth2/token") ).ContinueWith(t => { if (!t.IsFaulted) { accessTokenStringElement.Caption = t.Result ["access_token"]; scopeStringElement.Caption = t.Result ["scope"]; BeginInvokeOnMainThread(delegate { loginViewController.ReloadData(); ListSalesforceResources(t.Result ["instance_url"], t.Result ["access_token"]); }); } else { Console.WriteLine("error"); } }); } loginViewController.ReloadData(); }; UIViewController vc = authenticator.GetUI(); loginViewController.PresentViewController(vc, true, null); }
void LoginToFacebook(bool allowCancel) { IOAuthClient.IOAuthClient auth = new PlatformOAuthClient(); auth.New(dialog, "temporaryKey", clientId: "App ID from https://developers.facebook.com/apps", scope: "", authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"), redirectUrl: new Uri("http://www.facebook.com/connect/login_success.html")); auth.AllowCancel = allowCancel; // If authorization succeeds or is canceled, .Completed will be fired. auth.Completed += (s, e) => { // We presented the UI, so it's up to us to dismiss it. dialog.DismissViewController(true, null); if (!e.IsAuthenticated) { facebookStatus.Caption = "Not authorized"; dialog.ReloadData(); return; } // Now that we're logged in, make a OAuth2 request to get the user's info. var request = auth.CreateRequest("GET", new Uri("https://graph.facebook.com/me"), null, e.Account); request.GetResponseAsync().ContinueWith(t => { if (t.IsFaulted) { facebookStatus.Caption = "Error: " + t.Exception.InnerException.Message; } else if (t.IsCanceled) { facebookStatus.Caption = "Canceled"; } else { var obj = JsonValue.Parse(t.Result.GetResponseText()); facebookStatus.Caption = "Logged in as " + obj["name"]; } dialog.ReloadData(); }, uiScheduler); }; auth.Start("Facebook login"); }
public void Share(Service service, UITextView t) { Item item = new Item { Text = "I'm sharing great things using Xamarin!", Links = new List <Uri> { new Uri("http://xamarin.com"), }, }; UIViewController vc = service.GetShareUI(item, shareResult => { dialog.DismissViewController(true, null); t.Text = service.Title + " shared: " + shareResult; }); dialog.PresentViewController(vc, true, null); }
void HandleSettingPresentServerSelection() { settingsVC.ShowServerSelectionEvent -= HandleSettingPresentServerSelection; dvc.DismissViewController(true, null); PresentServerSelection(false); }