anchor.diff:  }
   ----
   
  +.Kotlin
  +[source,kotlin,role="secondary"]
  +----
  +@Controller
  +class OAuth2ClientController {
  +
  +    @Autowired
  +    private lateinit var authorizedClientService: OAuth2AuthorizedClientService
  +
  +    @GetMapping("/")
  +    fun index(authentication: Authentication): String {
  +        val authorizedClient: OAuth2AuthorizedClient =
  +            this.authorizedClientService.loadAuthorizedClient("okta", authentication.getName());
  +        val accessToken = authorizedClient.accessToken
  +
  +        ...
  +
  +        return "index";
  +    }
  +}
  +----
  +====
  +
   [NOTE]
   Spring Boot 2.x auto-configuration registers an `OAuth2AuthorizedClientRepository` and/or `OAuth2AuthorizedClientService` `@Bean` in the `ApplicationContext`.
   However, the application may choose to override and register a custom `OAuth2AuthorizedClientRepository` or `OAuth2AuthorizedClientService` `@Bean`.
  
positive.code: }
  ----
  
  You may obtain the `OAuth2AccessToken` as follows:
  
  [source,java]
  ----
  @Controller
  public class OAuth2ClientController {
  
negative.code: }
  ----
  
  .Kotlin
  [source,kotlin,role="secondary"]
  ----
  @Controller
  class OAuth2ClientController {
      @Autowired
      private lateinit var authorizedClientManager: OAuth2AuthorizedClientManager
  
      @GetMapping("/")
      fun index(authentication: Authentication?,
                servletRequest: HttpServletRequest,
                servletResponse: HttpServletResponse): String {
          val authorizeRequest: OAuth2AuthorizeRequest = OAuth2AuthorizeRequest.withClientRegistrationId("okta")
                  .principal(authentication)
                  .attributes(Consumer {
                      it[HttpServletRequest::class.java.name] = servletRequest
                      it[HttpServletResponse::class.java.name] = servletResponse
                  })
                  .build()
          val authorizedClient = authorizedClientManager.authorize(authorizeRequest)
          val accessToken: OAuth2AccessToken = authorizedClient.accessToken
  
          ...
  
          return "index"
      }
  }
  ----
  ====
  
  [NOTE]
  `HttpServletRequest` and `HttpServletResponse` are both OPTIONAL attributes.
  If not provided, it will default to `ServletRequestAttributes` using `RequestContextHolder.getRequestAttributes()`.
  