How do i make a request with HttpClient in Angular5 with OIDC OAuthService for current user informations?

I need to make GETs through HttpClient to get information about users. How do i do it in a service?
Right now i was able to correctly login using this guide, but now i need to make http requests in my injectable service.
I’m new to the frontend world, new to Angular and new with Okta’s APIs and I’m not finding any complete yet simple example on how do it
Thank you for your attention.

Hello @Lamba92. You might want to check out Build a Basic CRUD App with Angular 5.0 and Spring Boot 2.0. It uses an HttpInterceptor to add an authorization header.

import { Injectable } from '@angular/core';
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { OktaAuthService } from '@okta/okta-angular';

@Injectable()
export class AuthInterceptor implements HttpInterceptor {

  constructor(private oktaAuth: OktaAuthService) {
  }

  intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {

    // Only add to localhost requests since Giphy's API fails when the request include a token
    if (request.url.indexOf('localhost') > -1) {
      request = request.clone({
        setHeaders: {
          Authorization: `Bearer ${this.oktaAuth.getAccessToken().accessToken}`
        }
      });
    }

    return next.handle(request);
  }
}

After you create an interceptor, you’ll need to register it in your app.module.ts:

import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { AuthInterceptor } from './shared/okta/auth.interceptor';

@NgModule({
  ...
  providers: [CarService, GiphyService,
    {provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true}
  ],
  ...
})
3 Likes

Thank you very much for you answer and article! They were really useful (perfect i’d say :stuck_out_tongue: since i was working on Spring as well). I am using Gradle 4.5.1 and Kotlin and I have few more questions on this:

  1. I correctly managed to upgrade Spring to 2.0.0.RC1 but when using the 0.2.0 version of your package many errors happen:

    • SLF4J: Class path contains multiple SLF4J bindings.
      SLF4J: Found binding in [jar:file:/C:/Users/lamba/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
      SLF4J: Found binding in [jar:file:/C:/Users/lamba/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.25/8dacf9514f0c707cbbcdd6fd699e8940d42fb54e/slf4j-simple-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
      SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
      SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

    • Error processing condition on com.okta.spring.oauth.OktaTokenServicesConfig$LocalTokenValidationConfig.authoritiesExtractor

    When using your 0.1.0 package version, IntelliJ IDEA says to me that okta.oauth.issuer and okta.oauth.clientId “Cannot resolve configuration property” even if it compiles and run correctly (I did not tried to access resources while logged in tho). Here’s my gradle.build file; notice that if i do not add any of your packages the code runs.

  2. In your guide you use Okta’s official Angular SDK while in a previous guide for Angular (the one I used previously) you recommended Manfred Steyer’s project to add OAuth 2 and OpenID. Do you recommend to migrate to the official one? In both yes and no cases, why?

For #1, I’d try upgrading to 0.3.0 or removing DevTools as a depencency.

The answer to #2 is that both will work, but you’ll get better support from us when you use the official Angular SDK.

Uhm, with 0.3.0 it say that RelaxedPropertyResolver class is missing, here’s a GitHub issue with the same problem and here’s the stacktrace:

"C:\Program Files\Java\jdk1.8.0_152\bin\java" -javaagent:D:\Programmi\IntelliJ\apps\IDEA-U\ch-0\173.4548.28\lib\idea_rt.jar=51257:D:\Programmi\IntelliJ\apps\IDEA-U\ch-0\173.4548.28\bin -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_152\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_152\jre\lib\rt.jar;D:\Progetti\IntelliJ IDEA\projector\out\production\classes;D:\Progetti\IntelliJ IDEA\projector\out\production\resources;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-actuator\2.0.0.RC1\951cbc3c3d5792062f0e8b1e54b139c84307835f\spring-boot-starter-actuator-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-data-jpa\2.0.0.RC1\dfd1f76cb7452b608b411e8d457cdb93af46d3a3\spring-boot-starter-data-jpa-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-data-rest\2.0.0.RC1\620c26704fe8ba28bd66f727ad53f7879bbc3e1e\spring-boot-starter-data-rest-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.0.0.RC1\371b7248b6d1e4e5e17803adc091379df8779cff\spring-boot-starter-web-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk8\1.2.21\86407aed2dc197bd5f61d16e759c4ff43678732a\kotlin-stdlib-jdk8-1.2.21.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-kotlin\2.9.3\e43cbb5b78585ddccb651ff9b32c4c3479943013\jackson-module-kotlin-2.9.3.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.2.21\3159ff5936aa570a90050d385cb717fbb6c1723a\kotlin-reflect-1.2.21.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.okta.spring\okta-spring-boot-starter\0.3.0\2ae3af63f2eba57e50a73bd6ae74a93c5299874e\okta-spring-boot-starter-0.3.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-aop\2.0.0.RC1\78c7892e3573642e001dc445bdd88e8b8a1ec30b\spring-boot-starter-aop-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-jdbc\2.0.0.RC1\2369b4c4d75da4cdd8c2d9b3df862b78d989748a\spring-boot-starter-jdbc-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-json\2.0.0.RC1\9742f2d9511b570b5d77b502ba0b8ae6e85722b0\spring-boot-starter-json-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.okta.spring\okta-spring-security-oauth2\0.3.0\d7f440cf37c6429b2c498cc1b70d09bc9b7dad61\okta-spring-security-oauth2-0.3.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.h2database\h2\1.4.196\dd0034398d593aa3588c6773faac429bbd9aea0e\h2-1.4.196.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-security\2.0.0.RC1\1ad491058375f290b79985ee61dd392d95f393fd\spring-boot-starter-security-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.0.0.RC1\16674d8e982d50b0d68046d191c52d2c14a0d24c\spring-boot-starter-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-actuator-autoconfigure\2.0.0.RC1\7dd9f5bd59b92f4ed1e80e52a3fa15587065f5b3\spring-boot-actuator-autoconfigure-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\io.micrometer\micrometer-core\1.0.0-rc.8\861d9cb7f67fc3d29bab395f50e751755fda1279\micrometer-core-1.0.0-rc.8.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.hibernate\hibernate-core\5.2.12.Final\ea479b6692e22c9b642dd4142db670e92d106544\hibernate-core-5.2.12.Final.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\javax.transaction\javax.transaction-api\1.2\d81aff979d603edd90dcd8db2abc1f4ce6479e3e\javax.transaction-api-1.2.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-jpa\2.0.3.RELEASE\a88dbb9ca8957b34f37d5db7415d53b472e956d3\spring-data-jpa-2.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aspects\5.0.3.RELEASE\8e1f82ef89bd74264e8aa4106b0a87029ce329ba\spring-aspects-5.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-rest-webmvc\3.0.3.RELEASE\f80feca39f697056c325dd4eccd7f1867e9a4b6d\spring-data-rest-webmvc-3.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\2.0.0.RC1\49e790b6257495beda71b28f30505e760d1caa93\spring-boot-starter-tomcat-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.hibernate.validator\hibernate-validator\6.0.7.Final\8b9d9c7ec8c73963ea0fe81912fc67711a4ef76\hibernate-validator-6.0.7.Final.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-rest-core\3.0.3.RELEASE\e90e3f1486742e83f74d8f071755b7b8f3f7eea4\spring-data-rest-core-3.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.hateoas\spring-hateoas\0.24.0.RELEASE\b6401a781a58e0b2ab95242a553683e04300fe69\spring-hateoas-0.24.0.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.0.3.RELEASE\ded72f3634f4fb5989b2ee145faa72a4430843c5\spring-webmvc-5.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.security\spring-security-web\5.0.1.RELEASE\55ee649a551a23f1efa528b8c9884624dc3a085\spring-security-web-5.0.1.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework\spring-web\5.0.3.RELEASE\5266e04bf799e523bfe163f0e5520799c216cbfb\spring-web-5.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk7\1.2.21\88bfff5aa470143a83b0bc5ec00c0be8cabd7cad\kotlin-stdlib-jdk7-1.2.21.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.2.21\d64187eb2d9d1521be3421aa8c6774a8625cdde8\kotlin-stdlib-1.2.21.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.9.3\7d739db3f7975d082acbbade17986d018dc473c2\jackson-datatype-jsr310-2.9.3.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.9.3\75004a75b8a4d5927211141a679951d39999e6c4\jackson-datatype-jdk8-2.9.3.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.9.3\34c22452e76a4074ef47070c2f5e7a1f0ff95d7\jackson-module-parameter-names-2.9.3.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.okta.spring\okta-spring-sdk\0.3.0\b5dfb91ebd13e41c75d1d7021c01c6b2e14382b\okta-spring-sdk-0.3.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.okta.spring\okta-spring-config\0.3.0\93c9517b63143e9e40d002d2bce26207dfeaa3ea\okta-spring-config-0.3.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.okta.sdk\okta-sdk-httpclient\0.10.0\b8bc65d4066b0b9018cbe60edd7fc05e31f9e7c1\okta-sdk-httpclient-0.10.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.okta.sdk\okta-sdk-impl\0.10.0\5b058624872b0df774a5e806b63b9eaddbb6b6ee\okta-sdk-impl-0.10.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.9.3\193b96ef555b2f2573b576887ba9a93e4bf48e8c\jackson-databind-2.9.3.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.9.0\7c10d545325e3a6e72e06381afe469fd40eb701\jackson-annotations-2.9.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.0.0.RC1\8f0047cbc44852c9aa169f2156a4f430dd366a99\spring-boot-autoconfigure-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-actuator\2.0.0.RC1\67b2db4f96267bbeca7876303dfaed679cc20e9\spring-boot-actuator-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.0.0.RC1\92feecd8f26ee86caf4e87443433ebcb3050047b\spring-boot-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.0.0.RC1\1f19faea5174c33adf1d8dfe915dbb3711262f32\spring-boot-starter-logging-2.0.0.RC1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\javax.annotation\javax.annotation-api\1.3.1\20a2c0583598d68b0835474bbe07792d4f3b219f\javax.annotation-api-1.3.1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.plugin\spring-plugin-core\1.2.0.RELEASE\f380e7760032e7d929184f8ad8a33716b75c0657\spring-plugin-core-1.2.0.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.security\spring-security-config\5.0.1.RELEASE\28390bde73094e23c8cef1b87d25a0bf7c02398a\spring-security-config-5.0.1.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.security\spring-security-core\5.0.1.RELEASE\87b04110bfd85745c84afba3d7cb1ff82b2bae65\spring-security-core-5.0.1.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\5.0.3.RELEASE\a7cb3317167059337d57a6ba92b7a95997322198\spring-context-5.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\5.0.3.RELEASE\25019c46a2fae8c0c4a17979665e0613949ea59f\spring-aop-5.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework\spring-orm\5.0.3.RELEASE\36c02f2975196512783f9a98c7290504c1224689\spring-orm-5.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jdbc\5.0.3.RELEASE\3d9683a2e23a693579ebe762eb7a0a468908603d\spring-jdbc-5.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework\spring-tx\5.0.3.RELEASE\18cb58265c9d10a1bccc9024ee98c43780f6b344\spring-tx-5.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.0.3.RELEASE\5ad306c5d88a7d8c5b12749e5add8671a1ac1414\spring-data-commons-2.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.0.3.RELEASE\c65a623d51721f6037505ce6c11e5d19edfa1c3a\spring-beans-5.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework\spring-expression\5.0.3.RELEASE\ffc2e3d88a0b6ac6669e764a71cc3b49001eda21\spring-expression-5.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework\spring-core\5.0.3.RELEASE\8950eb10c466a77677693dd495d4b6a26de315f4\spring-core-5.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.19\2d998d3d674b172a588e54ab619854d073f555b5\snakeyaml-1.19.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.hdrhistogram\HdrHistogram\2.1.10\9e1ac84eed220281841b75e72fb9de5a297fbf04\HdrHistogram-2.1.10.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.latencyutils\LatencyUtils\2.0.3\769c0b82cb2421c8256300e907298a9410a2a3d3\LatencyUtils-2.0.3.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.aspectj\aspectjweaver\1.8.13\ad94df2a28d658a40dc27bbaff6a1ce5fbf04e9b\aspectjweaver-1.8.13.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.zaxxer\HikariCP\2.7.6\7930c6554acb1adcc7865ec86a27e49337c6e161\HikariCP-2.7.6.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.hibernate.common\hibernate-commons-annotations\5.0.1.Final\71e1cff3fcb20d3b3af4f3363c3ddb24d33c6879\hibernate-commons-annotations-5.0.1.Final.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.3.1.Final\c46217ab74b532568c0ed31dc599db3048bd1b67\jboss-logging-3.3.1.Final.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.hibernate.javax.persistence\hibernate-jpa-2.1-api\1.0.0.Final\5e731d961297e5a07290bfaf3db1fbc8bbbf405a\hibernate-jpa-2.1-api-1.0.0.Final.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.javassist\javassist\3.22.0-CR2\44eaf0990dea92f4bca4b9931b2239c0e8756ee7\javassist-3.22.0-CR2.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\antlr\antlr\2.7.7\83cd2cd674a217ade95a4bb83a8a14f351f48bd0\antlr-2.7.7.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.jboss\jandex\2.0.3.Final\bfc4d6257dbff7a33a357f0de116be6ff951d849\jandex-2.0.3.Final.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.fasterxml\classmate\1.3.4\3d5f48f10bbe4eb7bd862f10c0583be2e0053c6\classmate-1.3.4.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\dom4j\dom4j\1.6.1\5d3ccc056b6f056dbf0dddfdf43894b9065a8f94\dom4j-1.6.1.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.okta.sdk\okta-sdk-api\0.10.0\eecd4233f2f7259b89ca44c667deb90011c7e7cb\okta-sdk-api-0.10.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.3\7c4f3c474fb2c041d8028740440937705ebb473a\logback-classic-1.2.3.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.10.0\f7e631ccf49cfc0aefa4a2a728da7d374c05bd3c\log4j-to-slf4j-2.10.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.25\af5364cd6679bfffb114f0dec8a157aaa283b76\jul-to-slf4j-1.7.25.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-simple\1.7.25\8dacf9514f0c707cbbcdd6fd699e8940d42fb54e\slf4j-simple-1.7.25.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.slf4j\jcl-over-slf4j\1.7.25\f8c32b13ff142a513eeb5b6330b1588dcb2c0461\jcl-over-slf4j-1.7.25.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.25\da76ca59f6a57ee3102f8f9bd9cee742973efa8a\slf4j-api-1.7.25.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-websocket\8.5.27\3cba1c5187a17b0233de5712024d6e144036ba9a\tomcat-embed-websocket-8.5.27.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-core\8.5.27\a10612f0af27c7bfcc4e8d88393adad1fc5b4ece\tomcat-embed-core-8.5.27.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\8.5.27\5a591bcf5c930d2b37bb40c0f95180604a3b1a57\tomcat-embed-el-8.5.27.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\javax.validation\validation-api\2.0.1.Final\cb855558e6271b1b32e716d24cb85c7f583ce09e\validation-api-2.0.1.Final.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.jetbrains\annotations\13.0\919f0dfe192fb4e063e7dacadee7f8bb9a2672a9\annotations-13.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.9.3\ea9b6fc7bc3ccba9777b0827091f9aa1f8580371\jackson-core-2.9.3.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\javax.servlet\javax.servlet-api\3.1.0\3cd63d075497751784b2fa84be59432f4905bf7c\javax.servlet-api-3.1.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.security\spring-security-jwt\1.0.8.RELEASE\c7d3199e032027f1073e8039293be46e9be281e5\spring-security-jwt-1.0.8.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework.security.oauth\spring-security-oauth2\2.2.0.RELEASE\399b124299f1036806967d19782efae43b077788\spring-security-oauth2-2.2.0.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.mockito\mockito-core\2.13.0\8e372943974e4a121fb8617baced8ebfe46d54f0\mockito-core-2.13.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.0.3.RELEASE\855919d50380ed6f0ccee7b8d6789f4febdb6660\spring-jcl-5.0.3.RELEASE.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.atteo\evo-inflector\1.2.2\2551aad98d65ac5464d81fe05f0e1516cfe471c9\evo-inflector-1.2.2.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.bouncycastle\bcpkix-jdk15on\1.56\4648af70268b6fdb24674fb1fd7c1fcc73db1231\bcpkix-jdk15on-1.56.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\io.jsonwebtoken\jjwt\0.6.0\3c8a7897b9ca31c83d3dd364be7f75ce5cd417d7\jjwt-0.6.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\joda-time\joda-time\2.9.9\f7b520c458572890807d143670c9b24f4de90897\joda-time-2.9.9.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpclient\4.5.5\1603dfd56ebcd583ccdf337b6c3984ac55d89e58\httpclient-4.5.5.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy\1.7.9\51218a01a882c04d0aba8c028179cce488bbcb58\byte-buddy-1.7.9.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy-agent\1.7.9\a6c65f9da7f467ee1f02ff2841ffd3155aee2fc9\byte-buddy-agent-1.7.9.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.objenesis\objenesis\2.6\639033469776fd37c08358c6b92a4761feb2af4b\objenesis-2.6.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.3\864344400c3d4d92dfeb0a305dc87d953677c03c\logback-core-1.2.3.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.10.0\fec5797a55b786184a537abd39c3fa1449d752d6\log4j-api-2.10.0.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.bouncycastle\bcprov-jdk15on\1.56\a153c6f9744a3e9dd6feab5e210e1c9861362ec7\bcprov-jdk15on-1.56.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpcore\4.4.9\a86ce739e5a7175b4b234c290a00a5fdb80957a0\httpcore-4.4.9.jar;C:\Users\lamba\.gradle\caches\modules-2\files-2.1\commons-codec\commons-codec\1.11\3acb4705652e16236558f0f4f2192cc33c3bd189\commons-codec-1.11.jar" it.unito.projector.ProjectorApplication
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/lamba/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/lamba/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.25/8dacf9514f0c707cbbcdd6fd699e8940d42fb54e/slf4j-simple-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::            (v2.0.0.RC1)

2018-02-09 12:59:47.700  INFO 4004 --- [           main] i.u.p.ProjectorApplication$Companion     : Starting ProjectorApplication.Companion on Lambdaware-17 with PID 4004 (started by lamba in D:\Progetti\IntelliJ IDEA\projector)
2018-02-09 12:59:47.706  INFO 4004 --- [           main] i.u.p.ProjectorApplication$Companion     : No active profile set, falling back to default profiles: default
2018-02-09 12:59:47.827  INFO 4004 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7b9a4292: startup date [Fri Feb 09 12:59:47 CET 2018]; root of context hierarchy
2018-02-09 12:59:48.840  WARN 4004 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [it.unito.projector.ProjectorApplication]; nested exception is java.lang.IllegalStateException: Could not evaluate condition on com.okta.spring.sdk.OktaSdkConfig due to org/springframework/boot/bind/RelaxedPropertyResolver not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
2018-02-09 12:59:49.415  INFO 4004 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-02-09 12:59:49.429 ERROR 4004 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [it.unito.projector.ProjectorApplication]; nested exception is java.lang.IllegalStateException: Could not evaluate condition on com.okta.spring.sdk.OktaSdkConfig due to org/springframework/boot/bind/RelaxedPropertyResolver not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
	at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:616) ~[spring-context-5.0.3.RELEASE.jar:5.0.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:548) ~[spring-context-5.0.3.RELEASE.jar:5.0.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184) ~[spring-context-5.0.3.RELEASE.jar:5.0.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316) ~[spring-context-5.0.3.RELEASE.jar:5.0.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) ~[spring-context-5.0.3.RELEASE.jar:5.0.3.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-5.0.3.RELEASE.jar:5.0.3.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-context-5.0.3.RELEASE.jar:5.0.3.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693) ~[spring-context-5.0.3.RELEASE.jar:5.0.3.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.0.3.RELEASE.jar:5.0.3.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:138) ~[spring-boot-2.0.0.RC1.jar:2.0.0.RC1]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-2.0.0.RC1.jar:2.0.0.RC1]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) [spring-boot-2.0.0.RC1.jar:2.0.0.RC1]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.RC1.jar:2.0.0.RC1]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.0.RC1.jar:2.0.0.RC1]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) [spring-boot-2.0.0.RC1.jar:2.0.0.RC1]
	at it.unito.projector.ProjectorApplication$Companion.main(ProjectorApplication.kt:21) [classes/:na]
	at it.unito.projector.ProjectorApplication.main(ProjectorApplication.kt) [classes/:na]
Caused by: java.lang.IllegalStateException: Could not evaluate condition on com.okta.spring.sdk.OktaSdkConfig due to org/springframework/boot/bind/RelaxedPropertyResolver not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
	at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:55) ~[spring-boot-autoconfigure-2.0.0.RC1.jar:2.0.0.RC1]
	at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:109) ~[spring-context-5.0.3.RELEASE.jar:5.0.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:217) ~[spring-context-5.0.3.RELEASE.jar:5.0.3.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:606) ~[spring-context-5.0.3.RELEASE.jar:5.0.3.RELEASE]
	... 16 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver
	at com.okta.spring.sdk.OktaSdkConfig$OktaApiTokenCondition.getMatchOutcome(OktaSdkConfig.java:122) ~[okta-spring-sdk-0.3.0.jar:0.3.0]
	at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-2.0.0.RC1.jar:2.0.0.RC1]
	... 19 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_152]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_152]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_152]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_152]
	... 21 common frames omitted


Process finished with exit code 1

EDIT: Well I managed to solve the multiple SLF4J issue excluding one import from your package (look here for more information):

compile ('com.okta.spring:okta-spring-boot-starter:+') {
		exclude group: 'org.slf4j', module: 'slf4j-simple'
	}

or

compile('org.springframework.boot:spring-boot-starter-web'){
        exclude group: 'ch.qos.logback', module: 'logback-classic'
    }

EDIT 2: I posted the issue on your GitHub project, as bdemers recommended, I rolled back to springBootVersion = '1.5.10.RELEASE' and everything works using:

compile ('com.okta.spring:okta-spring-boot-starter:+') {
		exclude group: 'org.slf4j', module: 'slf4j-simple'
	}

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.