code: protected String getAccessToken(Authentication authentication) {
          String accessToken;
  
          try {
              Response response = getResponseForAccessTokenRequestFrom(authentication);
  
              if (!isOkay(response)) {
                  throw new AuthenticationServiceException("Got HTTP error code from OAuth2 provider: "
                          + response.getStatus());
              }
  
              Map<String,Object> userData = getUserDataMapFrom(response);
              // Check to see if there was an error or not
              if (userData.containsKey("error")) {
                  String output = response.readEntity(String.class);
                  LOGGER.error("Got error response from the OAuth Provider, output={}",
                          output);
                  throw new AuthenticationServiceException("Credentials were rejected by the OAuth Provider, output=" + output);
              }
  
              accessToken = (String)userData.get(oAuth2ServiceProperties.getAccessTokenName());
  
          } catch (WebApplicationException | ProcessingException e) {
              LOGGER.error("Error thrown by Jersey client when exchanging code for token", e);
              throw new AuthenticationServiceException("Error thrown by Jersey client when exchanging code for token", e);
          }
  
          return accessToken;
      }
docs: Exchange the current {@link Authentication}, which should be an instance of {@link OAuth2AuthenticationToken}
  containing an OAuth2 code as the credential, for an OAuth2 token.
  @param authentication Expected to be an instance of a {@link OAuth2AuthenticationToken}.
  @return The OAuth2 token from the OAuth Provider.