Skip to content

Instantly share code, notes, and snippets.

@dogeared
Forked from mraible/application.yml
Last active January 10, 2019 01:19
Show Gist options
  • Save dogeared/d767fbb1226ecfe2540a7fd06fcdde63 to your computer and use it in GitHub Desktop.
Save dogeared/d767fbb1226ecfe2540a7fd06fcdde63 to your computer and use it in GitHub Desktop.
Get an ID Token from Okta with Spring Boot

To Run:

OKTA_OAUTH2_ISSUER=https://{yourOktaDomain}/oauth2/default \
OKTA_OAUTH2_CLIENT-ID={clientId} \
OKTA_OAUTH2_CLIENT-SECRET={clientSecret} \
spring run idtoken.groovy
@Grab('com.okta.spring:okta-spring-boot-starter:1.0.0')
@RestController
class Application {
@GetMapping('/')
String home(@org.springframework.security.core.annotation.AuthenticationPrincipal(expression = "idToken") org.springframework.security.oauth2.core.oidc.OidcIdToken idToken) {
idToken.getTokenValue()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment