public async Task Can_authenticate_with_passwordless_email_code() { // Arrange var authenticationApiClient = new AuthenticationApiClient(new Uri(GetVariable("AUTH0_AUTHENTICATION_API_URL"))); // Arrange var authenticationResponse = await authenticationApiClient.Authenticate(new AuthenticationRequest { ClientId = GetVariable("AUTH0_CLIENT_ID"), Connection = "email", GrantType = "password", Scope = "openid", Username = "******", Password = "******" }); authenticationResponse.Should().NotBeNull(); }
static async Task <int> AsyncMain(string[] args) { Console.WriteLine("Press ENTER to call the API."); Console.ReadLine(); // Get a token using the Authentication client var client = new AuthenticationApiClient(new Uri("https://{DOMAIN}")); var token = await client.Authenticate(new AuthenticationRequest { ClientId = "{CLIENT_ID}", Connection = "Username-Password-Authentication", Username = "******", Password = "******", Scope = "openid profile" }); // Create a new HttpClient, and set the Auth header to the token we obtained var apiClient = new HttpClient(); apiClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.IdToken); // Call the API, and extract the response var response = await apiClient.GetAsync("http://localhost:25100/api/sample"); var content = await response.Content.ReadAsAsync <IEnumerable <ClaimItem> >(); Console.WriteLine("Call complete. Data received:"); // Write all the claims received from the API to the console foreach (var item in content) { Console.WriteLine(" > {0}: {1}", item.Type, item.Value); } Console.ReadLine(); // Return A-OK return(0); }
public async Task Can_authenticate_user_with_plus_in_username() { // Arrange var authenticationApiClient = new AuthenticationApiClient(new Uri(GetVariable("AUTH0_AUTHENTICATION_API_URL"))); // Act var authenticationResponse = await authenticationApiClient.Authenticate(new AuthenticationRequest { ClientId = GetVariable("AUTH0_CLIENT_ID"), Connection = connection.Name, GrantType = "password", Scope = "openid", Username = plusUser.Email, Password = "******" }); // Assert authenticationResponse.Should().NotBeNull(); }