'Signs request and returns signed Authorization header.'

def _oauth_sign(self, url, body, content_type=u'application/x-www-form-urlencoded', method=u'POST'):

    client_key = self.server.config.get('client_key', self.DEFAULT_CLIENT_KEY)
    client_secret = self.server.config.get('client_secret', self.DEFAULT_CLIENT_SECRET)
    client = oauthlib.oauth1.Client(client_key=unicode(client_key), client_secret=unicode(client_secret))
    headers = {'Content-Type': content_type}
    sha1 = hashlib.sha1()
    sha1.update(body)
    oauth_body_hash = unicode(base64.b64encode(sha1.digest()))
    mock_request = mock.Mock(uri=unicode(urllib.unquote(url)), headers=headers, body=u'', decoded_body=u'', http_method=unicode(method))
    params = client.get_oauth_params(mock_request)
    mock_request.oauth_params = params
    mock_request.oauth_params.append((u'oauth_body_hash', oauth_body_hash))
    sig = client.get_oauth_signature(mock_request)
    mock_request.oauth_params.append((u'oauth_signature', sig))
    new_headers = parameters.prepare_headers(mock_request.oauth_params, headers, realm=None)
    return new_headers['Authorization']
