public Connection < ? > completeConnection ( OAuth2ConnectionFactory < ? > connectionFactory , NativeWebRequest request ) { if ( connectionFactory . supportsStateParameter ( ) ) { verifyStateParameter ( request ) ; } String code = request . getParameter ( "code" ) ; try { AccessGrant accessGrant = connectionFactory . getOAuthOperations ( ) . exchangeForAccess ( code , callbackUrl ( request ) , null ) ; return connectionFactory . createConnection ( accessGrant ) ; } catch ( HttpClientErrorException e ) { logger . warn ( "HttpClientErrorException while completing connection: " + e . getMessage ( ) ) ; logger . warn ( " Response body: " + e . getResponseBodyAsString ( ) ) ; throw e ; } }
Complete the connection to the OAuth2 provider .