Created
January 10, 2019 00:28
-
-
Save mraible/476470f37a19d4b83c2d36a2ca6f9d63 to your computer and use it in GitHub Desktop.
Get an ID Token from Okta with Spring Boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
okta: | |
oauth2: | |
issuer: https://{yourOktaDomain}/oauth2/default | |
client-id: {clientId} | |
client-secret: {clientSecret} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('com.okta.spring:okta-spring-boot-starter:1.0.0') | |
import org.springframework.security.core.annotation.AuthenticationPrincipal; | |
import org.springframework.security.oauth2.core.oidc.OidcIdToken; | |
@RestController | |
class Application { | |
@GetMapping('/') | |
String home(@AuthenticationPrincipal(expression = "idToken") OidcIdToken idToken) { | |
idToken.getTokenValue() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put both files in the same directory. Install the Spring Boot CLI, then run:
Hit http://localhost:8080 after you start it, it’ll prompt you to log in, then you’ll see the ID token on the resulting screen.