Cant use "authenticate" from AuthenticationClient

I want to authenticate a user using username and password. I found on github (GitHub - okta/okta-auth-java: okta-auth-java) how it is done. I have all needed dependencys.

The method “authenticate” from “AuthenticationClient” throws an “com.okta.authn.sdk.AuthenticationException”. This “AuthenticationException” implements “com.okta.sdk.error.Error”, but my IDE does not find this class. I found out, that it can be found in an very old “okta-sdk-api” version, but then other things are not working.

How can it be? Is there a new way how to authenticate using username and password?

Hi there, are you using one of our sample/examples in Okta Java Auth SDK GitHub - okta/okta-auth-java: okta-auth-java? Could you please share what examples are you using?
Also what are the versions of the Java Auth SDK and Okta SDK API are you using? i.e. version of GitHub - okta/okta-sdk-java: A Java SDK for interacting with the Okta management API, enabling server-side code to manage Okta users, groups, applications, and more. and GitHub - okta/okta-auth-java: okta-auth-java

Hi, I got it to function using a regular http request, that is not elegant:

HttpRequest request = HttpRequest.newBuilder()
.uri(new URI(oktaURL + “/api/v1/authn”))
.header(“Accept”, “application/json”)
.header(“Content-Type”, “application/json”)
.header(“User-Agent”, “Mozilla/5.0 (systemInformation) platform (platformDetails) extensions”)
.POST(httpRequest)
.build();

Previously I tried it using the okta api with version as stated here GitHub - okta/okta-auth-java: okta-auth-java. I tried it again with that in my pom.xml. I used “okta-http-httpclient” instead, because the other one used in github is deprecated as stated in maven repo:

    <dependency>
        <groupId>com.okta.sdk</groupId>
		<artifactId>okta-sdk-api</artifactId>
		<version>19.0.1</version>
	</dependency>

	<dependency>
		<groupId>com.okta.sdk</groupId>
		<artifactId>okta-sdk-impl</artifactId>
		<version>19.0.1</version>
	</dependency>

	<dependency>
		<groupId>com.okta.commons</groupId>
		<artifactId>okta-http-httpclient</artifactId>
		<version>2.0.1</version>
	</dependency>

And that’s the code from the above github, that I used:

Now it even does not find the import for the class “AuthenticationClient”. How is that possible? The whole documentation in github is simply deprecated.