Works fine in developer account, but not in organisation account
I followed the instructions here: https://github.com/okta/samples-js-react/tree/master/okta-hosted-login
And here: https://github.com/okta/samples-java-spring/tree/master/resource-server
...to set up a sample reactjs app authenticating with Okta.
Worked like a charm with my developer Okta account.
But when I tried to use my organisation's Okta configurations, I'm encounter errors while trying to bring up the resource server.
Here are the configurations in my application.yml:
okta:
oauth2:
issuer: "https://<myOrgName>.okta-emea.com/oauth2/default"
client-id: "<myClientId>"
client-secret: "<myClientSecret>"
I created a new application in Okta developer console with a Web configuration, which gave me the clientId and clientSecret.
And when I do this:
cd resource-server
mvn
I see this error:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.8.RELEASE:run (default-cli) on project okta-spring-boot-oauth-resource-server: An exception occurred while running. null: InvocationTargetException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.security.oauth2.resource.OAuth2ResourceServerConfiguration]; nested exception is java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwkTokenStoreConfiguration: 401 Unauthorized -> [Help 1]
Any pointers on what I'm missing? How can I troubleshoot what is going wrong? Any logs in Okta?
Hi @premkumar-gg,
Couple of reasons this could be happening.
- Okta's Developer accounts have a
defaultauthorization server included as a part of the API Access Management product. You can validate if you have this feature enabled for your production org by visiting the meta-data endpoint:https://{yourOktaName}.okta-emea.com/oauth2/default/.well-known/oauth-authorization-server.- If you get a JSON response, you should have this enabled. If not, please contact [email protected]
- Your resource server is returning a
401 unauthorizederror. It is possible that your frontend is requesting tokens for your dev org, while your resource server is expecting them to be from your production org. Verify that theissuerclaim is equal for both.
Hope this provides a bit if guidance!
@premkumar-gg Some time has passed since this issue was filed. Were you able to resolve the issue?
It was quite some time ago. From what I remember, it happened that my organisation account package has not subscribed to the Okta APIs. The RoI for the cost of changing the subscription was not suitable, so we had to drop the idea.