Hello All,
I am trying to create Client using OAuth2ClientCredentials instead of TokenClientCredentials. But I don’t see any examples, most of the example that I see is using TokenClientCredentials.
Below is what I have so far, and since it seems DefaultClientBuilder looks for okta.yml or okta.properties file, I have created okta.properties file and added it to classpath.
In okta.properties file I have added all the properties mentioned in below Okta SDK okta.properties file, here okta-sdk-java/okta.properties at master · okta/okta-sdk-java · GitHub
DefaultClientBuilder defaultClientBuilder = new DefaultClientBuilder();
ClientConfiguration clientConfiguration = defaultClientBuilder.getClientConfiguration();
AccessTokenRetrieverService accessTokenRetrieverService =
new AccessTokenRetrieverServiceImpl(clientConfiguration);
Clients.builder()
.setOrgUrl(orgUrl)
.setClientCredentials(new OAuth2ClientCredentials(accessTokenRetrieverService))
.build();
Below error I see
Caused by: java.lang.NullPointerException: null
at com.okta.sdk.impl.config.ClientConfiguration.getRequestAuthenticator(ClientConfiguration.java:185)
at com.okta.sdk.impl.config.ClientConfiguration.toString(ClientConfiguration.java:213)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)