Skip to content

String Index Out Of Range (bare) / 401 (with /oauth2/default) - when using example #7

@MarcelTon

Description

@MarcelTon

I can not run the server with "our company" configuration and am unsure why. After creating an SPA Client in Okta with OpenID Connect I clone the project. I adjust the configuration as follows:

  1. http://localhost:4200/implicit/callback set as Login redirect URI in Okta
  2. Adjust my application yaml and app module typescript as shown below
  3. Test if https://company.okta.com/.well-known/openid-configuration works (it does with the real company name)

application.yml:

    okta:
      oauth2:
        client-id: 20-digit-Client-ID-string
        issuer: https://company.okta.com

app.module.ts:

    const config = {
      issuer: 'https://company.okta.com',
      redirectUri: 'http://localhost:4200/implicit/callback',
      clientId: '20-digit-Client-ID-string'
    };

Java version:

java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)

Maven version:

Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T20:41:47+02:00)
Maven home: /usr/local/Cellar/maven/3.6.0/libexec
Java version: 1.8.0_192, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/jre
Default locale: en_NL, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.6", arch: "x86_64", family: "mac"

JAVA_HOME:

/Users/m.ton/.jenv/versions/oracle64-1.8.0.192

If I then run ./mvnw spring-boot:run from the server folder I get the following error:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE:run (default-cli) on project demo: An exception occurred while running. null: InvocationTargetException: Error creating bean with name 'okta.client-com.okta.spring.config.OktaClientProperties': Could not bind properties to 'OktaClientProperties' : prefix=okta.client, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'okta.client.org-url' to java.lang.String: String index out of range: -1 -> [Help 1]

If I change my config to the below "default" from the clone my backend runs just fine.

application.yml:

    okta:
      oauth2:
        client-id: 0oagqzcu86BBOq2jF0h7
        issuer: https://dev-737523.oktapreview.com/oauth2/default

Obviously I can't onboard users that way haha, but it runs. If I use
https://company.okta.com/oauth2/default by the way (this isn't what is shown in the Issuer field in Okta, but just in case) I receive the following error:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE:run (default-cli) on project demo: 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]

Could you tell me what I can try/provide to get it running on my machine? I'm at my wits end. Using Java11 + the Issuer as shown in Okta gives the same error, albeit formatted a little differently:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.0.RELEASE:run (default-cli) on project demo: An exception occurred while running. null: InvocationTargetException: Error creating bean with name 'okta.client-com.okta.spring.config.OktaClientProperties': Could not bind properties to 'OktaClientProperties' : prefix=okta.client, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'okta.client.org-url' to java.lang.String: begin 0, end -1, length 25 -> [Help 1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions