KindeK
Kinde4w ago
pharg

Email + Password login for integration testing

Hi,

I cannot seem to find in docs how I can authenticate a user via email+password using only the .Net SDK or REST API.

I authenticate dev and test users for my api integration testing, how can I acheive this with Kinde ?

Ps. just migrating from Auth0 where I could do this.

Here is what I have, just need to fill in the missing line somehow......


public class KindeTestHelper
{
    public static async Task<string> GetAccessTokenAsync(string domain, string clientId, string clientSecret,
        string audience, string scopes, string realm, string username, string password)
    {
        var client = new KindeClient(new ApplicationConfiguration(domain, "", ""), new KindeHttpClient());
        await client.Authorize(new ClientCredentialsConfiguration(clientId, scopes, clientSecret, audience));

        // How to authenticate a test user and get an access token
        
        var accessToken = await client.GetToken();
        

        return accessToken;
    }
}



AND HERE is Auth0 way:

public class Auth0TestHelper
{
    // Login and get auth token
    public static async Task<string> GetAccessTokenAsync(string domain, string clientId, string clientSecret,
        string audience, string scopes, string realm, string username, string password)
    {
        var authenticationApiClient = new AuthenticationApiClient(new Uri($"https://{domain}"));

        var result = await authenticationApiClient.GetTokenAsync(new ResourceOwnerTokenRequest {
            ClientId = clientId,
            ClientSecret = clientSecret,
            Audience = audience,
            Scope = scopes,
            Realm = realm,
            Username = username,
            Password = password
        });

        var accessToken = result.AccessToken;

        return accessToken;
    }
}
Was this page helpful?