public static void Authenticate(this KZApplication application, KZApplication.OnEventHandler onAuthFinish) { PassiveAuthSettings = new Dictionary <string, string>(); if (!application.Initialized) { application.Initialize().Wait(); } KidozenApplicationConfig = application.ApplicationConfiguration; PassiveAuthSettings.Add("grant_type", "refresh_token"); PassiveAuthSettings.Add("client_secret", application.applicationKey); PassiveAuthSettings.Add("client_id", Validate(KidozenApplicationConfig, "domain")); PassiveAuthSettings.Add("scope", Validate(KidozenApplicationConfig.Value <JObject> ("authConfig"), "applicationScope")); PassiveAuthSettings.Add("oauthTokenEndpoint", Validate(KidozenApplicationConfig.Value <JObject> ("authConfig"), "oauthTokenEndpoint")); var signInUrl = Validate(KidozenApplicationConfig.Value <JObject> ("authConfig"), "signInUrl"); var authController = new PassiveAuthViewController(signInUrl); var wv = new UINavigationController(authController); authController.AuthenticationResponseArrived += (object sender, AuthenticationResponseEventArgs e) => { Console.WriteLine("*** Success : " + e.Success); application.Authenticated = e.Success; if (e.Success) { application.PassiveAuthenticationInformation = new Dictionary <string, string>(e.TokenInfo); } else { //TODO: display alert } if (onAuthFinish != null) { onAuthFinish.Invoke(application, e); } }; UIApplication.SharedApplication.Delegate.Window.RootViewController.PresentViewController(wv, true, new NSAction(() => { Console.WriteLine("loading"); })); //OnPassiveAuthentication.Invoke(application, new PassiveAuthenticationEventArgs {Success=e.Success}); }
public static void Authenticate (this KZApplication application, KZApplication.OnEventHandler onAuthFinish) { PassiveAuthSettings = new Dictionary<string, string>(); if (!application.Initialized) application.Initialize ().Wait (); KidozenApplicationConfig = application.ApplicationConfiguration; PassiveAuthSettings.Add ("grant_type", "refresh_token"); PassiveAuthSettings.Add ("client_secret", application.applicationKey); PassiveAuthSettings.Add ("client_id", Validate (KidozenApplicationConfig, "domain")); PassiveAuthSettings.Add ("scope", Validate (KidozenApplicationConfig.Value<JObject> ("authConfig"), "applicationScope")); PassiveAuthSettings.Add ("oauthTokenEndpoint", Validate (KidozenApplicationConfig.Value<JObject> ("authConfig"), "oauthTokenEndpoint")); var signInUrl = Validate (KidozenApplicationConfig.Value<JObject> ("authConfig"), "signInUrl"); var authController = new PassiveAuthViewController (signInUrl); var wv = new UINavigationController (authController); authController.AuthenticationResponseArrived+= (object sender, AuthenticationResponseEventArgs e) => { Console.WriteLine("*** Success : " + e.Success); application.Authenticated = e.Success; if(e.Success) { application.PassiveAuthenticationInformation = new Dictionary<string,string>( e.TokenInfo); } else { //TODO: display alert } if(onAuthFinish!=null) { onAuthFinish.Invoke(application, e); } }; UIApplication.SharedApplication.Delegate.Window.RootViewController.PresentViewController (wv, true, new NSAction(()=>{ Console.WriteLine("loading"); })); //OnPassiveAuthentication.Invoke(application, new PassiveAuthenticationEventArgs {Success=e.Success}); }