title: Bitbucket API OAuth not redirecting properly
body: <p>I'm trying to set up Bitbucket OAuth for my site but for some reason Bitbucket is not properly redirecting back to my site. I've created an OAuth key and secret and I'm using the Guzzle OAuth plugin in my Silex application.</p>
  
  <p>First I request a temporary token via the oauth/request_token endpoint. Using that token I redirect to oauth/authenticate endpoint:</p>
  
  <pre><code>$app-&gt;get(
      '/auth/bitbucket',
      function () use ($app) {
          $client = new Client('https://bitbucket.org/api/1.0');
          $oauth = new OauthPlugin(
              array(
                  'consumer_key' =&gt; $app['bitbucket.key'],
                  'consumer_secret' =&gt; $app['bitbucket.secret'],
                  'signature_method' =&gt; 'HMAC-SHA1',
                  'callback' =&gt; urlencode('http://mysite.local/auth/bitbucket/callback')
              )
          );
          $client-&gt;addSubscriber($oauth);
  
          $response = $client-&gt;post('oauth/request_token')-&gt;send();
  
          parse_str($response-&gt;getBody(), $result);
  
          return $app-&gt;redirect(sprintf('https://bitbucket.org/api/1.0/oauth/authenticate?oauth_token=%s', $result['oauth_token']));
      }
  );
  </code></pre>
  
  <p>This will bring up the page on the Bitbucket site where the user can grant or deny access to their account. After I click "Grant access" Bitbucket should redirect back to the callback url that was specified earlier but instead it will append my callback url to the Bitbucket url like this:</p>
  
  <p><a href="https://bitbucket.org/api/1.0/oauth/http%3A%2F%2Fmysite.local%2Fauth%2Fbitbucket%2Fcallback?oauth_verifier=xxxxxxxxxx&amp;oauth_token=xxxxxxxxxxxxxxxxxx" rel="nofollow">https://bitbucket.org/api/1.0/oauth/http%3A%2F%2Fmysite.local%2Fauth%2Fbitbucket%2Fcallback?oauth_verifier=xxxxxxxxxx&amp;oauth_token=xxxxxxxxxxxxxxxxxx</a></p>
  
  <p>This obviously results in a Bitbucket 404 page. Does anyone have an idea why the redirect to my callback url is not working properly?</p>