Redirecting to external validation page using oauth with drupal_http_request() I'm working on a module to integrate with the Piryx API, and per the OAuth documentation, I should be redirected to an external page where the user can allow access to my application.  The problem is that I'm using drupal_http_request():

$response = drupal_http_request($url, $headers, 'GET', $data);


to get the data, and the page markup is returned in $response['data'] instead of redirecting me to the external page (if I put the URL in my browser, it brings up the page fine).  Is there something I can do to redirect to the external URL so the user can allow access, or do I just somehow need to use the markup to display it in my site?

Thanks.
In the case the request is redirect to a different URL, $response-&gt;code is 301, and $response-&gt;redirect_url is the redirection URL. If the request is redirect, you can call drupal_http_request() using $response-&gt;redirect_url as new URL.

See aggregator_aggregator_fetch() as example of Drupal function that verifies the request is being redirected.

  // Process HTTP response code.
  switch ($result-&gt;code) {
    case 304:
      break;
    case 301:
      $feed-&gt;url = $result-&gt;redirect_url;
      // Do not break here.
    case 200:
    case 302:
    case 307:
      if (!isset($result-&gt;data)) {
        $result-&gt;data = '';
      }
      if (!isset($result-&gt;headers)) {
        $result-&gt;headers = array();
      }
      $feed-&gt;source_string = $result-&gt;data;
      $feed-&gt;http_headers = $result-&gt;headers;
      break;
    default:
      watchdog('aggregator', 'The feed from %site seems to be broken, due to "%error".', array('%site' =&gt; $feed-&gt;title, '%error' =&gt; $result-&gt;code . ' ' . $result-&gt;error), WATCHDOG_WARNING);
      drupal_set_message(t('The feed from %site seems to be broken, because of error "%error".', array('%site' =&gt; $feed-&gt;title, '%error' =&gt; $result-&gt;code . ' ' . $result-&gt;error)));
  }


If you want to redirect the users to $result-&gt;redirect_url, and not requesting that URL with drupal_http_request(), you use the following code.

drupal_goto($response-&gt;redirect_url, array('absolute' =&gt; TRUE));