https://developer.zendesk.com/rest_api/docs/core/oauth_clients#create-client
326683
def oauth_client_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/oauth/clients.json"
        return self.call(api_path, method="POST", data=data, **kwargs)
600625
function createConnection(connectionOptions, config)
  {
    // create a new ConnectionConfig and skip credential-validation if a config
    // object has been specified; this is because if a config object has been
    // specified, we're trying to deserialize a connection and the account name,
    // username and password don't need to be specified because the config
    // object already contains the tokens we need
    var connectionConfig =
        new ConnectionConfig(connectionOptions, !config, qaMode, clientInfo);

    // if an http client was specified in the options passed to the module, use
    // it, otherwise create a new HttpClient
    var httpClient = options.httpClient ||
            new options.httpClientClass(connectionConfig);

    return new connectionClass(
        new ConnectionContext(connectionConfig, httpClient, config));
  }
98855
def request(method, path, opts = {})
      raise ClientError, 'Access token missing' unless @access_token

      opts[:headers] = {} if opts[:headers].nil?
      opts[:headers]['Accept'] = 'application/json'
      opts[:headers]['Content-Type'] = 'application/json' unless method == :get
      opts[:headers]['User-Agent'] = user_agent
      opts[:body] = MultiJson.encode(opts[:data]) if !opts[:data].nil?
      path = URI.encode(path)

      # Reset the URL in case the environment / base URL has been changed.
      @oauth_client.site = base_url

      header_keys = opts[:headers].keys.map(&:to_s)
      if header_keys.map(&:downcase).include?('authorization')
        @oauth_client.request(method, path, opts)
      else
        @access_token.send(method, path, opts)
      end
    rescue OAuth2::Error => err
      raise GoCardless::ApiError.new(err.response)
    end
921149
function makeRequest (path, params) {
    // The api key will always be sent as a query parameter
    params = params || {}
    params.token = apiKey

    return new Promise(function (resolve, reject) {
      request(`${hostname}${path}?${querystring.stringify(params)}`,
        function (error, response, body) {
          if (error) {
            reject(error)
          }
          try {
            var result = JSON.parse(body)
            if (response.statusCode === 200) {
              resolve(result)
            }
            reject(result.error)
          } catch (error) {
            reject(response.statusMessage)
          }
        })
    })
  }
684896
def _client(self, id, secret):
        """"""
        url = self.api_url + self.auth_token_url
        auth_string = '%s:%s' % (id, secret)
        authorization = base64.b64encode(auth_string.encode()).decode()
        headers = {
            'Authorization': "Basic " + authorization,
            'Content-Type': "application/x-www-form-urlencoded"
        }
        params = {
            'grant_type': 'client_credentials',
            'response_type': 'token'
        }
        return self.session.post(url, params=params, headers=headers)
1103089
def create_client(self, name):
        ''''''
        client = {'client':{
            'name': name,
        }}
        response = self.post_request('clients/', client, follow = True)
        if response:
            return Client(self, response['client'])
53256
def create(self, **kwargs):
        """"""
        url_str = self.base_url
        if 'tenant_id' in kwargs:
            url_str = url_str + '?tenant_id=%s' % kwargs['tenant_id']
            del kwargs['tenant_id']

        data = kwargs['jsonbody'] if 'jsonbody' in kwargs else kwargs
        body = self.client.create(url=url_str, json=data)
        return body
450349
def create_token(credential, opts = {})
      data, _status_code, _headers = create_token_with_http_info(credential, opts)
      return data
    end
951261
def create(self, company, timezone, country):
        """"""

        body = {
            "CompanyName": company,
            "TimeZone": timezone,
            "Country": country}
        response = self._post("/clients.json", json.dumps(body))
        self.client_id = json_to_py(response)
        return self.client_id
35980
def get_client(provider, token=''):
    ""
    cls = OAuth2Client
    if provider.request_token_url:
        cls = OAuthClient
    return cls(provider, token)
651070
private Client createRestClient() throws KeyManagementException, NoSuchAlgorithmException {
		ClientConfig clientConfig = new ClientConfig();
		// Set connection timeout
		if (this.connectionTimeout != 0) {
			clientConfig.property(ClientProperties.CONNECT_TIMEOUT, this.connectionTimeout);
			clientConfig.property(ClientProperties.READ_TIMEOUT, this.connectionTimeout);
		}

		
		clientConfig.register(MoxyJsonFeature.class).register(MoxyXmlFeature.class).register(createMoxyJsonResolver());
		
		Client client = null;
		if (this.baseURI.startsWith("https")) {
			client = createSLLClient(clientConfig);
		} else {
			client = ClientBuilder.newClient(clientConfig);
		}

		return client;
	}
1151753
def _generate_bearer_token(consumer_key, consumer_secret):
    
    data = [('grant_type', 'client_credentials')]
    resp = requests.post(OAUTH_ENDPOINT,
                         data=data,
                         auth=(consumer_key, consumer_secret))
    logger.warning("Grabbing bearer token from OAUTH")
    if resp.status_code >= 400:
        logger.error(resp.text)
        resp.raise_for_status()

    return resp.json()['access_token']
963178
def create_client(self, client_id, client_secret):
        
        assert self.is_admin, "Must authenticate() as admin to create client"
        return self.uaac.create_client(client_id, client_secret)
801172
def create_http_client
      options = {
        :api_version => API_VERSION,
        :open_timeout => DEFAULT_OPEN_TIMEOUT,
        :request_timeout => DEFAULT_REQUEST_TIMEOUT,
        :non_blocking => @non_blocking }
      auth_url = URI.parse(@api_url)
      auth_url.user = @token_id.to_s
      auth_url.password = @token
      @http_client = RightScale::BalancedHttpClient.new(auth_url.to_s, options)
    end
340318
def build_connection
      RestClient.log = config.logger if config.logger
      RestClient::Resource.new(config.base_url, config.options.merge(auth_options))
    end
240839
def Create(cls, discovery_doc,
               scope_ls, client_id, client_secret, user_agent, names, api_key):
        """"""
        scopes = set(
            discovery_doc.get('auth', {}).get('oauth2', {}).get('scopes', {}))
        scopes.update(scope_ls)
        package = discovery_doc['name']
        url_version = discovery_doc['version']
        base_url, base_path = _ComputePaths(package, url_version,
                                            discovery_doc)

        client_info = {
            'package': package,
            'version': NormalizeVersion(discovery_doc['version']),
            'url_version': url_version,
            'scopes': sorted(list(scopes)),
            'client_id': client_id,
            'client_secret': client_secret,
            'user_agent': user_agent,
            'api_key': api_key,
            'base_url': base_url,
            'base_path': base_path,
        }
        client_class_name = '%s%s' % (
            names.ClassName(client_info['package']),
            names.ClassName(client_info['version']))
        client_info['client_class_name'] = client_class_name
        return cls(**client_info)
168697
def create_from_code(self, code, user=None):
        

        # perform code exchange
        logger.debug("Creating new token from code {0}".format(code[:-5]))
        oauth = OAuth2Session(app_settings.ESI_SSO_CLIENT_ID, redirect_uri=app_settings.ESI_SSO_CALLBACK_URL)
        token = oauth.fetch_token(app_settings.ESI_TOKEN_URL, client_secret=app_settings.ESI_SSO_CLIENT_SECRET,
                                  code=code)
        r = oauth.request('get', app_settings.ESI_TOKEN_VERIFY_URL)
        r.raise_for_status()
        token_data = r.json()
        logger.debug(token_data)

        # translate returned data to a model
        model = self.create(
            character_id=token_data['CharacterID'],
            character_name=token_data['CharacterName'],
            character_owner_hash=token_data['CharacterOwnerHash'],
            access_token=token['access_token'],
            refresh_token=token['refresh_token'],
            token_type=token_data['TokenType'],
            user=user,
        )

        # parse scopes
        if 'Scopes' in token_data:
            from esi.models import Scope
            for s in token_data['Scopes'].split():
                try:
                    scope = Scope.objects.get(name=s)
                    model.scopes.add(scope)
                except Scope.DoesNotExist:
                    # This scope isn't included in a data migration. Create a placeholder until it updates.
                    try:
                        help_text = s.split('.')[1].replace('_', ' ').capitalize()
                    except IndexError:
                        # Unusual scope name, missing periods.
                        help_text = s.replace('_', ' ').capitalize()
                    scope = Scope.objects.create(name=s, help_text=help_text)
                    model.scopes.add(scope)
            logger.debug("Added {0} scopes to new token.".format(model.scopes.all().count()))

        if not app_settings.ESI_ALWAYS_CREATE_TOKEN:
            # see if we already have a token for this character and scope combination
            # if so, we don't need a new one
            queryset = self.get_queryset().equivalent_to(model)
            if queryset.exists():
                logger.debug(
                    "Identified {0} tokens equivalent to new token. Updating access and refresh tokens.".format(
                        queryset.count()))
                queryset.update(
                    access_token=model.access_token,
                    refresh_token=model.refresh_token,
                    created=model.created,
                )
                if queryset.filter(user=model.user).exists():
                    logger.debug("Equivalent token with same user exists. Deleting new token.")
                    model.delete()
                    model = queryset.filter(user=model.user)[0]  # pick one at random

        logger.debug("Successfully created {0} for user {1}".format(repr(model), user))
        return model