private async void LoginButton_OnClick(object sender, RoutedEventArgs e) { try { var user = await auth0Client.LoginAsync(); UserInfoTextBox.Text = user.Profile.ToString(); } catch (Exception ex) { UserInfoTextBox.Text = ex.Message; } }
private void LoginWithWidget_Click(object sender, RoutedEventArgs e) { auth0.LoginAsync(new WindowWrapper(new WindowInteropHelper(this).Handle)).ContinueWith(t => { if (t.IsFaulted) { this.textBox1.Text = t.Exception.InnerException.ToString(); } else { this.textBox1.Text = t.Result.Profile.ToString(); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
private async void button_Click(object sender, RoutedEventArgs e) { resultTextBox.Text = ""; var loginResult = await _auth0Client.LoginAsync(); // Display error if (loginResult.IsError) { resultTextBox.Text = loginResult.Error; return; } // Display result StringBuilder sb = new StringBuilder(); sb.AppendLine("Tokens"); sb.AppendLine("------"); sb.AppendLine($"id_token: {loginResult.IdentityToken}"); sb.AppendLine($"access_token: {loginResult.AccessToken}"); sb.AppendLine($"refresh_token: {loginResult.RefreshToken}"); sb.AppendLine(); sb.AppendLine("Claims"); sb.AppendLine("------"); foreach (var claim in loginResult.User.Claims) { sb.AppendLine($"{claim.Type}: {claim.Value}"); } resultTextBox.Text = sb.ToString(); }
public async Task <bool> Authenticate() { var cached = _tokenCache.GetUser(); if (cached == null) { var authClient = new Auth0Client(Domain, ClientId); var result = await authClient.LoginAsync() .ContinueWith(t => t.Result, TaskScheduler.FromCurrentSynchronizationContext()); if (result == null) { return(false); } AuthenticatedUser = result; _tokenCache.StoreUser(result); } else { AuthenticatedUser = cached; } return(true); }
private async void OnLogin(object sender, EventArgs e) { var domain = ConfigurationManager.AppSettings["auth0.domain"].ToSecureString(); var client = ConfigurationManager.AppSettings["auth0.client.id"].ToSecureString(); var audience = ConfigurationManager.AppSettings["auth0.audience"].ToSecureString(); var options = new Auth0ClientOptions { Domain = domain.ToUnsecureString(), ClientId = client.ToUnsecureString() }; var auth0 = new Auth0Client(options); options.PostLogoutRedirectUri = options.RedirectUri; var param = new Dictionary <string, string>() { { "audience", audience.ToUnsecureString() } }; Hide(); var login = await auth0.LoginAsync(param); if (login.IsError) { Show(); } }
private async Task LoginAsync() { var loginResult = await _auth0Client.LoginAsync(); if (!loginResult.IsError) { var name = loginResult.User.FindFirst(c => c.Type == "name")?.Value; var email = loginResult.User.FindFirst(c => c.Type == "email")?.Value; var image = loginResult.User.FindFirst(c => c.Type == "picture")?.Value; var userProfile = new UserProfile { Email = email, Name = name, ProfilePictureUrl = image }; UIStoryboard board = UIStoryboard.FromName("Main", null); UserProfileViewController userProfileViewController = (UserProfileViewController)board.InstantiateViewController("UserProfileViewController"); userProfileViewController.UserProfile = userProfile; this.PresentViewController(userProfileViewController, true, null); } else { Console.WriteLine($"An error occurred during login: {loginResult.Error}"); } }
public async Task <AuthenticationResult> Authenticate() { var auth0LoginResult = await _auth0Client.LoginAsync(new { audience = AuthenticationConfig.Audience }); AuthenticationResult authenticationResult; if (auth0LoginResult.IsError == false) { IsAuthenticated = true; authenticationResult = new AuthenticationResult() { AccessToken = auth0LoginResult.AccessToken, IdToken = auth0LoginResult.IdentityToken, UserClaims = auth0LoginResult.User.Claims }; } else { authenticationResult = new AuthenticationResult(auth0LoginResult.IsError, auth0LoginResult.Error); } AuthenticationResult = authenticationResult; return(authenticationResult); }
public async Task <UserLogin> Login(string username, string password) { UserLogin user = null; var externalLoginConfigurationService = DependencyService.Get <IExternalLoginConfigurationService>(); try { var auth0 = new Auth0Client(externalLoginConfigurationService.Auth0Domain, externalLoginConfigurationService.Auth0ClientId); if (auth0 != null) { var aDFSUser = await auth0.LoginAsync(externalLoginConfigurationService.Auth0ConnectionName, username, password); if (aDFSUser != null) { Console.WriteLine("Logged in as " + aDFSUser.Profile["name"]); } } return(user); } catch (TaskCanceledException ex) { var navigationService = DependencyService.Get <INavigationService>(); await navigationService.PopAsync(); } catch (Exception ex) { throw ex; } return(null); }
private async void LoginButton_Click(object sender, RoutedEventArgs e) { string domain = "{DOMAIN}"; string clientId = "{CLIENT_ID}"; client = new Auth0Client(new Auth0ClientOptions { Domain = domain, ClientId = clientId }); var extraParameters = new Dictionary <string, string>(); if (!string.IsNullOrEmpty(connectionNameAutoSuggestBox.Text)) { extraParameters.Add("connection", connectionNameAutoSuggestBox.Text); } if (!string.IsNullOrEmpty(audienceTextBox.Text)) { extraParameters.Add("audience", audienceTextBox.Text); } DisplayResult(await client.LoginAsync(extraParameters: extraParameters)); }
public async Task <AuthenticationResult> Authenticate() { var auth0LoginResult = await _auth0Client.LoginAsync(new { audience = AppSettings.Configuration.Auth.Audience, }); AuthenticationResult authenticationResult; if (!auth0LoginResult.IsError) { authenticationResult = new AuthenticationResult() { AccessToken = auth0LoginResult.AccessToken, IdToken = auth0LoginResult.IdentityToken, UserClaims = auth0LoginResult.User.Claims }; await SecureStorage.SetAsync(RefreshToken, auth0LoginResult.RefreshToken); } else { authenticationResult = new AuthenticationResult(auth0LoginResult.IsError, auth0LoginResult.Error); } return(authenticationResult); }
private async void LoginButton_Click(object sender, EventArgs e) { string domain = ConfigurationManager.AppSettings["Auth0:Domain"]; string clientId = ConfigurationManager.AppSettings["Auth0:ClientId"]; client = new Auth0Client(new Auth0ClientOptions { Domain = domain, ClientId = clientId }); var extraParameters = new Dictionary <string, string>(); if (!string.IsNullOrEmpty(connectionNameComboBox.Text)) { extraParameters.Add("connection", connectionNameComboBox.Text); } if (!string.IsNullOrEmpty(audienceTextBox.Text)) { extraParameters.Add("audience", audienceTextBox.Text); } DisplayResult(await client.LoginAsync(extraParameters: extraParameters)); }
private async void LoginButton_TouchUpInside(object sender, EventArgs e) { var client = new Auth0Client(new Auth0ClientOptions { Domain = "ash123.auth0.com", ClientId = "nwJxiC7ILZnVMabtAaGif9MNTagMpwXM", Controller = this }); var loginResult = await client.LoginAsync(); var sb = new StringBuilder(); if (loginResult.IsError) { sb.AppendLine("An error occurred during login:"******"ID Token: {loginResult.IdentityToken}"); sb.AppendLine($"Access Token: {loginResult.AccessToken}"); sb.AppendLine($"Refresh Token: {loginResult.RefreshToken}"); sb.AppendLine(); sb.AppendLine("-- Claims --"); foreach (var claim in loginResult.User.Claims) { sb.AppendLine($"{claim.Type} = {claim.Value}"); } } UserDetailsTextView.Text = sb.ToString(); }
private async void LoginButton_TouchUpInside(object sender, EventArgs e) { _client = new Auth0Client(new Auth0ClientOptions { Domain = "{DOMAIN}", ClientId = "{CLIENT_ID}", Scope = "openid profile" }); var loginResult = await _client.LoginAsync(); var sb = new StringBuilder(); if (loginResult.IsError) { sb.AppendLine("An error occurred during login:"******"ID Token: {loginResult.IdentityToken}"); sb.AppendLine($"Access Token: {loginResult.AccessToken}"); sb.AppendLine($"Refresh Token: {loginResult.RefreshToken}"); sb.AppendLine(); sb.AppendLine("-- Claims --"); foreach (var claim in loginResult.User.Claims) { sb.AppendLine($"{claim.Type} = {claim.Value}"); } } UserDetailsTextView.Text = sb.ToString(); }
public async Task <LoginResult> AuthenticateAsync() { string domain = ConfigurationManager.AppSettings["Auth0:Domain"]; string clientId = ConfigurationManager.AppSettings["Auth0:ClientId"]; string audience = ConfigurationManager.AppSettings["Auth0:Audience"]; string connection = ConfigurationManager.AppSettings["Auth0:Connection"]; string scope = ConfigurationManager.AppSettings["Auth0:Scope"]; _client = new Auth0Client(new Auth0ClientOptions { Domain = domain, ClientId = clientId, Browser = new EdgeWebView("Tanka Chat for WPF sample", 600, 810), Scope = scope }); var extraParameters = new Dictionary <string, string>() { { "connection", connection }, { "audience", audience } }; var loginResult = await _client.LoginAsync(extraParameters : extraParameters); if (loginResult.IsError) { // Handle errors on the caller. Debug.WriteLine(loginResult.Error); } return(loginResult); }
private async void LoginButtonOnClick(object sender, EventArgs eventArgs) { _userDetailsTextView.Text = "Starting Login process..."; var loginResult = await _client.LoginAsync(); _userDetailsTextView.Text = BuildLoginResultMessage(loginResult); }
private async void LoginButton_OnClick(object sender, RoutedEventArgs e) { string domain = ConfigurationManager.AppSettings["Auth0:Domain"]; string clientId = ConfigurationManager.AppSettings["Auth0:ClientId"]; var client = new Auth0Client(new Auth0ClientOptions { Domain = domain, ClientId = clientId, Browser = new SystemWebBrowser(), RedirectUri = "http://127.0.0.1:7890/" }); var extraParameters = new Dictionary <string, string>(); if (!string.IsNullOrEmpty(connectionNameComboBox.Text)) { extraParameters.Add("connection", connectionNameComboBox.Text); } if (!string.IsNullOrEmpty(audienceTextBox.Text)) { extraParameters.Add("audience", audienceTextBox.Text); } DisplayResult(await client.LoginAsync(extraParameters: extraParameters)); }
private async Task LoginAsync() { var loginResult = await _auth0Client.LoginAsync(); if (!loginResult.IsError) { var name = loginResult.User.FindFirst(c => c.Type == "name")?.Value; var email = loginResult.User.FindFirst(c => c.Type == "email")?.Value; var image = loginResult.User.FindFirst(c => c.Type == "picture")?.Value; var userProfile = new UserProfile { Email = email, Name = name, ProfilePictureUrl = image }; var intent = new Intent(this, typeof(UserProfileActivity)); var serializedLoginResponse = JsonConvert.SerializeObject(userProfile); intent.PutExtra("LoginResult", serializedLoginResponse); StartActivity(intent); } else { Console.WriteLine($"An error occurred during login: {loginResult.Error}"); } }
private async void LoginButtonOnClick(object sender, EventArgs eventArgs) { clearText(); writeLine("Starting login..."); var loginResult = await _auth0Client.LoginAsync(); if (loginResult.IsError) { writeLine($"An error occurred during login: {loginResult.Error}"); return; } accessToken = loginResult.AccessToken; writeLine($"id_token: {loginResult.IdentityToken}"); writeLine($"access_token: {loginResult.AccessToken}"); writeLine($"refresh_token: {loginResult.RefreshToken}"); writeLine($"name: {loginResult.User.FindFirst(c => c.Type == "name")?.Value}"); writeLine($"email: {loginResult.User.FindFirst(c => c.Type == "email")?.Value}"); foreach (var claim in loginResult.User.Claims) { writeLine($"{claim.Type} = {claim.Value}"); } }
public async Task <AuthenticationResult> Login() { try { var authUser = await _client.LoginAsync(new AndroidLoginPage().Context, Auth0Settings.AdfsConnection, true); var authToken = authUser.Profile.ToObject <AuthToken>(); authToken.IdToken = authUser.IdToken; authToken.AccessToken = authUser.Auth0AccessToken; authToken.RefreshToken = authUser.RefreshToken; Insights.Identify(authToken); return(new AuthenticationResult(authToken, AuthenticationStatus.Succeded)); } catch (TaskCanceledException cancelException) { AuthenticationStatus authenticationStatus = AuthenticationStatus.Failed; if (cancelException.Task != null && cancelException.Task.Status == TaskStatus.Canceled) { authenticationStatus = AuthenticationStatus.Canceled; } return(new AuthenticationResult(null, authenticationStatus, cancelException)); } catch (Exception exception) { return(new AuthenticationResult(null, AuthenticationStatus.Failed, exception)); } }
public async Task <AuthenticationResult> Login() { try { var authUser = await _client.LoginAsync(AppDelegate.RootViewController, Auth0Settings.AdfsConnection, true, "openid email name nickname given_name family_name"); var authToken = authUser.Profile.ToObject <AuthToken>(); authToken.IdToken = authUser.IdToken; authToken.AccessToken = authUser.Auth0AccessToken; authToken.RefreshToken = authUser.RefreshToken; Insights.Identify(authToken); return(new AuthenticationResult(authToken, AuthenticationStatus.Succeded)); } catch (TaskCanceledException cancelException) { AuthenticationStatus authenticationStatus = AuthenticationStatus.Failed; if (cancelException.Task != null && cancelException.Task.Status == TaskStatus.Canceled) { authenticationStatus = AuthenticationStatus.Canceled; } return(new AuthenticationResult(null, authenticationStatus, cancelException)); } catch (Exception exception) { Insights.Report(exception); return(new AuthenticationResult(null, AuthenticationStatus.Failed, exception)); } }
private async void button1_Click(object sender, EventArgs e) { var client = new Auth0Client(new Auth0ClientOptions { Domain = "jerrie.auth0.com", ClientId = "vV9twaySQzfGesS9Qs6gOgqDsYDdgoKE" }); var loginResult = await client.LoginAsync(); if (loginResult.IsError) { Debug.WriteLine($"An error occurred during login: {loginResult.Error}"); } else { Debug.WriteLine($"id_token: {loginResult.IdentityToken}"); Debug.WriteLine($"access_token: {loginResult.AccessToken}"); Debug.WriteLine($"refresh_token: {loginResult.RefreshToken}"); Debug.WriteLine($"name: {loginResult.User.FindFirst(c => c.Type == "name")?.Value}"); Debug.WriteLine($"email: {loginResult.User.FindFirst(c => c.Type == "email")?.Value}"); foreach (var claim in loginResult.User.Claims) { Debug.WriteLine($"{claim.Type} = {claim.Value}"); } } }
private async void LoginButton_Click(object sender, RoutedEventArgs e) { outputText.Text = ""; writeLine("Logging in..."); var loginResult = await _auth0Client.LoginAsync(); if (loginResult.IsError) { writeLine($"An error occurred during login: {loginResult.Error}"); } else { accessToken = loginResult.AccessToken; writeLine($"id_token: {loginResult.IdentityToken}"); writeLine($"access_token: {loginResult.AccessToken}"); writeLine($"refresh_token: {loginResult.RefreshToken}"); writeLine($"name: {loginResult.User.FindFirst(c => c.Type == "name")?.Value}"); writeLine($"email: {loginResult.User.FindFirst(c => c.Type == "email")?.Value}"); foreach (var claim in loginResult.User.Claims) { writeLine($"{claim.Type} = {claim.Value}"); } } }
private async void button_Click(object sender, RoutedEventArgs e) { var client = new Auth0Client(new Auth0ClientOptions { Domain = "jerrie.auth0.com", ClientId = "vV9twaySQzfGesS9Qs6gOgqDsYDdgoKE", Scope = "openid profile offline_access", Browser = new SystemWebBrowser(), RedirectUri = "http://127.0.0.1:7890/" }); var loginResult = await client.LoginAsync(); if (loginResult.IsError) { Debug.WriteLine($"An error occurred during login: {loginResult.Error}"); } else { Debug.WriteLine($"id_token: {loginResult.IdentityToken}"); Debug.WriteLine($"access_token: {loginResult.AccessToken}"); Debug.WriteLine($"refresh_token: {loginResult.RefreshToken}"); Debug.WriteLine($"name: {loginResult.User.FindFirst(c => c.Type == "name")?.Value}"); Debug.WriteLine($"email: {loginResult.User.FindFirst(c => c.Type == "email")?.Value}"); foreach (var claim in loginResult.User.Claims) { Debug.WriteLine($"{claim.Type} = {claim.Value}"); } } }
private async void LoginButton_TouchUpInside(object sender, EventArgs e) { _client = new Auth0Client(new Auth0ClientOptions { Domain = "jerrie.auth0.com", ClientId = "vV9twaySQzfGesS9Qs6gOgqDsYDdgoKE" }); var loginResult = await _client.LoginAsync(null); var sb = new StringBuilder(); if (loginResult.IsError) { sb.AppendLine("An error occurred during login:"******"ID Token: {loginResult.IdentityToken}"); sb.AppendLine($"Access Token: {loginResult.AccessToken}"); sb.AppendLine($"Refresh Token: {loginResult.RefreshToken}"); sb.AppendLine(); sb.AppendLine("-- Claims --"); foreach (var claim in loginResult.User.Claims) { sb.AppendLine($"{claim.Type} = {claim.Value}"); } } UserDetailsTextView.Text = sb.ToString(); }
private async void LoginButtonOnClick(object sender, EventArgs eventArgs) { _userDetailsTextView.Text = ""; // Call the login method var loginResult = await _client.LoginAsync(); var sb = new StringBuilder(); if (loginResult.IsError) { sb.AppendLine($"An error occurred during login: {loginResult.Error}"); } else { sb.AppendLine($"ID Token: {loginResult.IdentityToken}"); sb.AppendLine($"Access Token: {loginResult.AccessToken}"); sb.AppendLine($"Refresh Token: {loginResult.RefreshToken}"); sb.AppendLine(); sb.AppendLine("-- Claims --"); foreach (var claim in loginResult.User.Claims) { sb.AppendLine($"{claim.Type} = {claim.Value}"); } } _userDetailsTextView.Text = sb.ToString(); }
public async Task StartSignInAsync() { AuthData authData = null; var domain = Settings.AuthDomain; var clientId = Settings.AuthClientId; var audience = Settings.AuthAudience; var client = new Auth0Client(new Auth0ClientOptions { Domain = domain, ClientId = clientId }); try { var result = await client.LoginAsync(new { audience = audience }); if (result.IsError) { authData = new AuthData("Login error!", false, null, null, string.Format("Error occured: {0}", result.Error)); } else { authData = new AuthData(GetAuthUsername(result.User), true, result.AccessToken, result.AccessTokenExpiration, null); } } catch (Exception ex) { authData = new AuthData("Login error!", false, null, null, string.Format("Error occured: {0}", ex.Message)); } AuthData = authData; }
public override async void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); if (_cancelledByUser || _justLoggedIn) { return; } Auth0Client auth0Client = null; //IdentityService identityService = null; if (_nativeView == null) { return; } var message = String.Empty; try { auth0Client = new Auth0Client(App.Instance.OAuthSettings.Domain, App.Instance.OAuthSettings.ClientId); //SimpleIoc.Default.GetInstance<Auth0Client>(); //identityService = SimpleIoc.Default.GetInstance<IIdentityService>() as IdentityService; //if (identityService == null) return; var user = await auth0Client.LoginAsync(ViewController, "servcorp.adfs.prod", true); _justLoggedIn = true; // if (eventArgs.IsAuthenticated) { // // Use eventArgs.Account to do wonderful things App.Instance.SaveToken(user.Auth0AccessToken); App.Instance.SuccessfulLoginAction.Invoke(); // } else { // // The user cancelled // } } catch (System.Threading.Tasks.TaskCanceledException cancelException) { App.Instance.FailureLoginAction.Invoke(); //await App.Instance.NavigationPage.Navigation.PushModalAsync (new StartPage()); MessagingCenter.Send <App> (App.Instance, "AuthenticationFailed"); if (cancelException.Task != null && cancelException.Task.Status == TaskStatus.Canceled) { _cancelledByUser = true; } message = cancelException.Message; App.Instance.ErrorMessage = message; App.Instance.NavigationPage.PopToRootAsync().Wait(); } catch (Exception exception) { message = exception.Message; //throw; } //if (identityService != null) identityService.SetIdentity(auth0Client, _cancelledByUser, message); }
private async void Login() { var auth0 = new Auth0Client( "majji.auth0.com", "sfBNUQUSidqrlTxSeQphLjZ2SJ8J49VI"); var user = await auth0.LoginAsync(); }
public override async void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); try { var loginAuth0PageRenderService = DependencyService.Get <ILoginAuth0PageRenderService>(); await loginAuth0PageRenderService.LoginWrapper(async() => { var externalLoginConfigurationService = DependencyService.Get <IExternalLoginConfigurationService>(); if (externalLoginConfigurationService == null) { throw new ArgumentNullException(nameof(externalLoginConfigurationService)); } var auth0 = new Auth0Client(externalLoginConfigurationService.Auth0Domain, externalLoginConfigurationService.Auth0ClientId); var user = await auth0.LoginAsync(ViewController, externalLoginConfigurationService.Auth0ConnectionName, false); if (user != null) { Console.WriteLine("Logged in as " + user.Profile["name"]); try { var userLogin = new UserLogin { UserProfile = new UserProfile { DisplayName = user.Profile.GetKeyValue("name"), Image = user.Profile.GetKeyValue("picture_large"), Email = user.Profile.GetKeyValue("email"), Facebook = user.Profile.GetKeyValue("link"), FirstName = user.Profile.GetKeyValue("given_name"), LastName = user.Profile.GetKeyValue("family_name") }, Auth0AccessToken = user.Auth0AccessToken, RefreshToken = user.RefreshToken, IdToken = user.IdToken, DateLogin = DateTime.Now }; return(userLogin); } catch (Exception e) { Console.WriteLine(e); throw; } } return(null); }); } catch (Exception e) { } }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { var auth0 = new Auth0Client( "mdocs.auth0.com", "kgKQd16fCm2ZH5w5UeiRHvUY0O2Z0gbK", "rEwJ0hKCocy4fk7OXdrsuQJRQwiBPLqqMBONiwnIWN2BFnuztthdeGsPeXc2Bh8X"); auth0.LoginAsync(null) .ContinueWith(Authenticated, TaskScheduler.FromCurrentSynchronizationContext()); }