spring-cloud-security/src/main/java/org/springframework/cloud/security/oauth2/client/feign/OAuth2FeignRequestInterceptor.java
public OAuth2AccessToken getToken() {

		OAuth2AccessToken accessToken = oAuth2ClientContext.getAccessToken();
		if (accessToken == null || accessToken.isExpired()) {
			try {
				accessToken = acquireAccessToken();
			}
			catch (UserRedirectRequiredException e) {
				oAuth2ClientContext.setAccessToken(null);
				String stateKey = e.getStateKey();
				if (stateKey != null) {
					Object stateToPreserve = e.getStateToPreserve();
					if (stateToPreserve == null) {
						stateToPreserve = "NONE";
					}
					oAuth2ClientContext.setPreservedState(stateKey, stateToPreserve);
				}
				throw e;
			}
		}
		return accessToken;
	}
public OAuth2AccessToken getToken() {

		OAuth2AccessToken accessToken = oAuth2ClientContext.getAccessToken();
		if (accessToken == null || accessToken.isExpired()) {
			try {
				accessToken = acquireAccessToken();
			}
			catch (UserRedirectRequiredException e) {
				oAuth2ClientContext.setAccessToken(null);
				String stateKey = e.getStateKey();
				if (stateKey != null) {
					Object stateToPreserve = e.getStateToPreserve();
					if (stateToPreserve == null) {
						stateToPreserve = "NONE";
					}
					oAuth2ClientContext.setPreservedState(stateKey, stateToPreserve);
				}
				throw e;
			}
		}
		return accessToken;
	}
public OAuth2AccessToken getToken ( ) { OAuth2AccessToken accessToken = oAuth2ClientContext . getAccessToken ( ) ; if ( accessToken == null || accessToken . isExpired ( ) ) { try { accessToken = acquireAccessToken ( ) ; } catch ( UserRedirectRequiredException e ) { oAuth2ClientContext . setAccessToken ( null ) ; String stateKey = e . getStateKey ( ) ; if ( stateKey != null ) { Object stateToPreserve = e . getStateToPreserve ( ) ; if ( stateToPreserve == null ) { stateToPreserve = "NONE" ; } oAuth2ClientContext . setPreservedState ( stateKey , stateToPreserve ) ; } throw e ; } } return accessToken ; }
Extract the access token within the request or try to acquire a new one by
delegating it to {@link #acquireAccessToken()}.
@return valid token
Extract the access token within the request or try to acquire a new one by delegating it to {