@Override protected HttpUriRequest setupConnection(HTTP_METHOD method, String bucketName, String objectKey, Map<String, String> requestParameters) throws ServiceException { final HttpUriRequest request = super.setupConnection(method, bucketName, objectKey, requestParameters); // Use API version 2 if we are using OAuth2 credentials if (getProviderCredentials() instanceof OAuth2Credentials) { request.setHeader("x-goog-api-version", "2"); } return request; }
@Override protected boolean isRecoverable403(HttpUriRequest httpRequest, Exception exception) { if (getProviderCredentials() instanceof OAuth2Credentials) { // Only retry if we're using OAuth2 authentication and can refresh the access token // TODO Any way to distinguish between expired access token and other 403 reasons? OAuth2Tokens tokens; try { tokens = ((OAuth2Credentials)getProviderCredentials()).getOAuth2Tokens(); } catch(IOException e) { return false; } if (tokens != null) { tokens.expireAccessToken(); return true; } } return super.isRecoverable403(httpRequest, exception); }
@Override protected HttpUriRequest setupConnection(HTTP_METHOD method, String bucketName, String objectKey, Map<String, String> requestParameters) throws ServiceException { final HttpUriRequest request = super.setupConnection(method, bucketName, objectKey, requestParameters); // Use API version 2 if we are using OAuth2 credentials if (getProviderCredentials() instanceof OAuth2Credentials) { request.setHeader("x-goog-api-version", "2"); } return request; }
@Override protected boolean isRecoverable403(HttpUriRequest httpRequest, Exception exception) { if (getProviderCredentials() instanceof OAuth2Credentials) { // Only retry if we're using OAuth2 authentication and can refresh the access token // TODO Any way to distinguish between expired access token and other 403 reasons? OAuth2Tokens tokens; try { tokens = ((OAuth2Credentials)getProviderCredentials()).getOAuth2Tokens(); } catch(IOException e) { return false; } if (tokens != null) { tokens.expireAccessToken(); return true; } } return super.isRecoverable403(httpRequest, exception); }
throws ServiceException if (getProviderCredentials() instanceof OAuth2Credentials) { OAuth2Tokens tokens; try { tokens = ((OAuth2Credentials)getProviderCredentials()).getOAuth2Tokens();
throws ServiceException if (getProviderCredentials() instanceof OAuth2Credentials) { OAuth2Tokens tokens; try { tokens = ((OAuth2Credentials)getProviderCredentials()).getOAuth2Tokens();