public void addAuthToken ( ClientRequest request , String token ) { if ( token != null && ! token . startsWith ( "Bearer " ) ) { if ( token . toUpperCase ( ) . startsWith ( "BEARER " ) ) { // other cases of Bearer token = "Bearer " + token . substring ( 7 ) ; } else { token = "Bearer " + token ; } } request . getRequestHeaders ( ) . put ( Headers . AUTHORIZATION , token ) ; }
Add Authorization Code grant token the caller app gets from OAuth2 server .