Build remote url request. Constructs necessary auth.
329633
def request(self, method, url, **kwargs):
        ""
        user_token = kwargs.pop('token', self.token)
        token, secret = self.parse_raw_token(user_token)
        callback = kwargs.pop('oauth_callback', None)
        verifier = kwargs.get('data', {}).pop('oauth_verifier', None)
        oauth = OAuth1(
            resource_owner_key=token,
            resource_owner_secret=secret,
            client_key=self.provider.consumer_key,
            client_secret=self.provider.consumer_secret,
            verifier=verifier,
            callback_uri=callback,
        )
        kwargs['auth'] = oauth
        return super(OAuthClient, self).request(method, url, **kwargs)
628863
def _construct_url(self, endpoint):
        """"""
        parsed_url = urlparse(self.host)
        scheme = parsed_url[0]
        host = parsed_url[1]
        # Handle host without a scheme specified (eg. www.example.com)
        if scheme == "":
            scheme = "http"
            host = self.host

        if not endpoint.startswith("/"):
            endpoint = "/" + endpoint
        if self.config["api_version"] is not None:
            endpoint = "/v%d%s" % (self.config["api_version"], endpoint)
        return urlunparse((scheme, host, endpoint, '', '', ''))
99725
protected function buildUrl() {
		$this->url = $this->baseUrl . '?' . http_build_query(['secret' => $this->secretKey, 'response' => $this->response]);
	}
882464
def authentication_url_from_master(master_url, auth_params)
      client = Kontena::Client.new(master_url)
      vspinner "Sending authentication request to receive an authorization URL" do
        response = client.request(
          http_method: :get,
          path: authentication_path(auth_params),
          expects: [501, 400, 302, 403],
          auth: false
        )

        if client.last_response.status == 302
          client.last_response.headers['Location']
        elsif response.kind_of?(Hash)
          exit_with_error [response['error'], response['error_description']].compact.join(' : ')
        elsif response.kind_of?(String) && response.length > 1
          exit_with_error response
        else
          exit_with_error "Invalid response to authentication request : HTTP#{client.last_response.status} #{client.last_response.body if debug?}"
        end
      end
    end
1198411
def build_http_request(klass, path, params = nil, body = nil)
      path += '?' + URI.encode_www_form(params) unless params.nil?
      req = klass.new(path)
      req.body = URI.encode_www_form(body) unless body.nil?
      Etcd::Log.debug("Built #{klass} path:'#{path}'  body:'#{req.body}'")
      req
    end
417236
def build_url_request(self):
        
        # Check if the ip is LAN or WAN
        if net.IPAddress(self.ip).is_private():
            url = "http://{}".format(self.ip)
            self.authentication_type = BboxConstant.AUTHENTICATION_TYPE_LOCAL
        else:
            url = "https://{}:{}".format(self.ip,
                                         BboxConstant.DEFAULT_REMOTE_PORT)
            self.authentication_type = BboxConstant.AUTHENTICATION_TYPE_REMOTE

        if self.api_class is None:
            url = "{}/{}".format(url, self.API_PREFIX)
        else:
            url = "{}/{}/{}".format(url, self.API_PREFIX, self.api_class)

        if self.api_method is None:
            self.url = url
        else:
            self.url = "{}/{}".format(url, self.api_method)
313529
def request(params={})
      normalize_parameters params
      raise UnmetRequirementsError, "Required parameters: #{requirements}" \
        unless meets_requirements? params
      credentials = pull_credentials params
      pairs = pull_url_pairs params
      request = construct_request expand_url(pairs), params, credentials
      yield request if block_given?
      request
    end
1348313
def request(self, method, url, **kwargs):
        """"""
        user_token = kwargs.pop('token', self.token)
        token, secret, expires_at = self.parse_raw_token(user_token)
        if token is not None:
            params = kwargs.get('params', {})
            params['access_token'] = token
            kwargs['params'] = params
        return super(OAuth2Provider, self).request(method, url, **kwargs)
1001930
async def fromURL(
            cls, url, *, credentials=None, insecure=False):
        """"""
        try:
            description = await helpers.fetch_api_description(
                url, insecure=insecure)
        except helpers.RemoteError as error:
            # For now just re-raise as SessionError.
            raise SessionError(str(error))
        else:
            session = cls(description, credentials)
            session.insecure = insecure
            return session
797198
def build(
        cls,
        *,
        scheme="",
        user="",
        password=None,
        host="",
        port=None,
        path="",
        query=None,
        query_string="",
        fragment="",
        encoded=False
    ):
        """"""

        if not host and scheme:
            raise ValueError('Can\'t build URL with "scheme" but without "host".')
        if port and not host:
            raise ValueError('Can\'t build URL with "port" but without "host".')
        if query and query_string:
            raise ValueError('Only one of "query" or "query_string" should be passed')
        if path is None or query_string is None or fragment is None:
            raise TypeError('NoneType is illegal for "path", "query_string" and '
                            '"fragment" args, use string values instead.')

        if not user and not password and not host and not port:
            netloc = ""
        else:
            netloc = cls._make_netloc(user, password, host, port, encode=not encoded)
        if not encoded:
            path = cls._PATH_QUOTER(path)
            if netloc:
                path = cls._normalize_path(path)

            cls._validate_authority_uri_abs_path(host=host, path=path)
            query_string = cls._QUERY_QUOTER(query_string)
            fragment = cls._FRAGMENT_QUOTER(fragment)

        url = cls(
            SplitResult(scheme, netloc, path, query_string, fragment), encoded=True
        )

        if query:
            return url.with_query(query)
        else:
            return url
972443
def _build_url(self):
        """"""
        if self.connection.get("username") and self.connection.get("password"):
            auth = "%s:%s@" % (self.connection["username"],
                               self._encoded_password)
            if self.connection.get("domain"):
                auth = r"%s;%s" % (self.connection["domain"], auth)
        else:
            auth = ""

        # Optional port number
        port = self.connection.get("port")
        port = ":" + port if port else ""

        # Construct mount_url
        self.connection["mount_url"] = "//%s%s%s/%s" % (
            auth, self.connection["url"], port, self.connection["share_name"])
225772
def _make_request(self, url, params=None, opener=None):
        
        # Create the request object
        args = [i for i in [url, params] if i]
        request = urllib.request.Request(*args)
        # If the client has credentials, include them as a header
        if self.username and self.password:
            credentials = '%s:%s' % (self.username, self.password)
            encoded_credentials = base64.encodestring(
                credentials.encode("utf-8")
            ).decode("utf-8").replace("\n", "")
            header = 'Basic %s' % encoded_credentials
            request.add_header('Authorization', header)
        # If the request provides a custom opener, like the upload request,
        # which relies on a multipart request, it is applied here.
        if opener:
            opener = urllib.request.build_opener(opener)
            request_method = opener.open
        else:
            request_method = urllib.request.urlopen
        # Make the request
        try:
            response = request_method(request)
        except Exception:
            e = sys.exc_info()[1]
            if getattr(e, 'code', None) == 404:
                raise DoesNotExistError("The resource you've requested does \
not exist or is unavailable without the proper credentials.")
            elif getattr(e, 'code', None) == 401:
                raise CredentialsFailedError("The resource you've requested \
requires proper credentials.")
            else:
                raise e
        # Read the response and return it
        return response.read()
113493
def _build_url(url, _params):
    """"""

    # Support for unicode domain names and paths.
    scheme, netloc, path, params, query, fragment = urlparse(url)
    netloc = netloc.encode('idna').decode('utf-8')
    if not path:
        path = '/'

    if six.PY2:
        if isinstance(scheme, six.text_type):
            scheme = scheme.encode('utf-8')
        if isinstance(netloc, six.text_type):
            netloc = netloc.encode('utf-8')
        if isinstance(path, six.text_type):
            path = path.encode('utf-8')
        if isinstance(params, six.text_type):
            params = params.encode('utf-8')
        if isinstance(query, six.text_type):
            query = query.encode('utf-8')
        if isinstance(fragment, six.text_type):
            fragment = fragment.encode('utf-8')

    enc_params = _encode_params(_params)
    if enc_params:
        if query:
            query = '%s&%s' % (query, enc_params)
        else:
            query = enc_params
    url = (urlunparse([scheme, netloc, path, params, query, fragment]))
    return url
1036886
function buildURL(dbName, opts) {
  var authentication
  opts.scheme = opts.scheme || 'http'
  opts.host   = opts.host   || '127.0.0.1'
  opts.port   = opts.port   || '5984'

  if (has(opts, 'auth')) {
    if (typeof opts.auth === 'object') {
      authentication = opts.auth.username + ':' + opts.auth.password + '@'
    }
  }

  return opts.scheme + '://' + authentication + opts.host + ':' + opts.port + '/' + dbName
}
1041425
def create_remote(self, name, url, **kwargs):
        """"""
        return Remote.create(self, name, url, **kwargs)
1177896
def build_url (self):
        
        super(TelnetUrl, self).build_url()
        # default port
        if self.port is None:
            self.port = 23
        # set user/pass
        self.user, self.password = self.get_user_password()
992811
def _construct_url(self, base_api, params):
        
        params['key'] = self.api_key
        return super(OpenMapQuest, self)._construct_url(base_api, params)