// Create a new OAuth client.
//
// name is the OAuth client name. redirectUri is the endpoint for redirection
// after authorization with OAuth client.
179739
func (c *Client) OAuthClientCreate(name string, redirectUri string) (*OAuthClient, error) {
	params := struct {
		Name        string `json:"name"`
		RedirectUri string `json:"redirect_uri"`
	}{
		Name:        name,
		RedirectUri: redirectUri,
	}
	var oauthClientRes OAuthClient
	return &oauthClientRes, c.Post(&oauthClientRes, "/oauth/clients", params)
}
1171374
func New(endpoint, secret string, skipverify bool) *Client {
	client := &Client{
		Accept:   "application/json",
		Encoding: "identity",
		Endpoint: endpoint,
		Secret:   secret,
	}
	if skipverify {
		client.Client = &http.Client{
			CheckRedirect: func(*http.Request, []*http.Request) error {
				return http.ErrUseLastResponse
			},
			Transport: &http.Transport{
				Proxy: http.ProxyFromEnvironment,
				TLSClientConfig: &tls.Config{
					InsecureSkipVerify: true,
				},
			},
		}
	}
	return client
}
682381
func NewClient(user, pass, base string) *Client {
	return &Client{
		ID:          user,
		Token:       pass,
		Client:      defaultHttpClient,
		Base:        base,
		UploadType:  JSON,
		ErrorParser: DefaultErrorParser,
	}
}
953552
func NewClient(opts ...ClientOption) *Client {
	client := &Client{
		client:  &http.Client{Timeout: defaultTimeout},
		baseURL: defaultBaseURL,
	}
	for _, opt := range opts {
		opt(client)
	}
	return client
}
850316
func NewClientToken(uri, token string) Client {
	config := new(oauth2.Config)
	auther := config.Client(oauth2.NoContext, &oauth2.Token{AccessToken: token})
	return &client{client: auther, base: uri, token: token}
}
835790
func NewClient(url string) *Client {
	return &Client{
		URL:    url,
		client: http.DefaultClient,
	}
}
987719
func NewClient(url string, httpClient *http.Client) *Client {
	if httpClient == nil {
		httpClient = http.DefaultClient
	}
	return &Client{
		url:        url,
		httpClient: httpClient,
	}
}
116853
func NewClient(username, password, baseURL string) (*Client, error) {
	ctx := oauth2.NoContext
	conf := NewConfig(username, password, baseURL)

	u, err := url.Parse(baseURL)
	if err != nil {
		return nil, err
	}

	c := &Client{
		HTTPClient: conf.Client(ctx),
		BaseURL:    u,
		UserAgent:  userAgent,
		Config:     conf,
	}
	c.Accounts = &AccountsService{client: c}
	c.Alerts = &AlertsService{client: c}
	c.DirectionalPools = &DirectionalPoolsService{client: c}
	c.Events = &EventsService{client: c}
	c.Notifications = &NotificationsService{client: c}
	c.Probes = &ProbesService{client: c}
	c.RRSets = &RRSetsService{client: c}
	c.Tasks = &TasksService{client: c}
	return c, nil
}
423850
func (p *Provider) Client(ctx context.Context, t *oauth2.Token) *http.Client {
	if p.NewClient != nil {
		return p.NewClient(ctx, t)
	}
	return p.Config.Client(ctx, t)
}
477152
func createHttpClient() *http.Client {
	tr := util.Transport(services.Config().GetString(util.ConfigfwdProxyPortURL))
	tr.MaxIdleConnsPerHost = maxIdleConnsPerHost
	client := &http.Client{
		Transport: tr,
		Timeout:   httpTimeout,
		CheckRedirect: func(req *http.Request, _ []*http.Request) error {
			req.Header.Set("Authorization", "Bearer "+services.Config().GetString(configBearerToken))
			return nil
		},
	}
	return client
}
301095
func (s *Service) OAuthAuthorizationCreate(ctx context.Context, o OAuthAuthorizationCreateOpts) (*OAuthAuthorization, error) {
	var oauthAuthorization OAuthAuthorization
	return &oauthAuthorization, s.Post(ctx, &oauthAuthorization, fmt.Sprintf("/oauth/authorizations"), o)
}
532414
func New(uri string) Client {
	return &client{http.DefaultClient, strings.TrimSuffix(uri, "/")}
}
864357
func NewHTTPClient(apiKeyPublic, apiKeyPrivate string) *HTTPClient {
	return &HTTPClient{
		apiKeyPublic:  apiKeyPublic,
		apiKeyPrivate: apiKeyPrivate,
		client:        http.DefaultClient,
	}
}
585407
func NewClient(uri string, cli *http.Client) Client {
	return &client{cli, strings.TrimSuffix(uri, "/")}
}
754748
func NewClient(config Config) Client {
	if config.AuthKey == "" {
		panic("failed to create Transloadit client: missing AuthKey")
	}

	if config.AuthSecret == "" {
		panic("failed to create Transloadit client: missing AuthSecret")
	}

	client := Client{
		config:     config,
		httpClient: &http.Client{},
	}

	return client
}
886354
func NewClient(auth Auth) *Client {
	return &Client{auth: auth, client: http.DefaultClient}
}
182680
func (c *TokensClient) CreateAuth(ctx context.Context, authorization string, authTokenRequest *AuthTokenRequest) (*AuthToken, error) {
	p := "/tokens/auth"

	req, err := c.backend.NewRequest(http.MethodPost, p, nil, authTokenRequest)
	if err != nil {
		return nil, err
	}

	req.Header.Set("authorization", authorization)

	var resp AuthToken
	_, err = c.backend.Do(ctx, req, &resp, func(code int) error {
		return &Error{}
	})
	if err != nil {
		return nil, err
	}

	return &resp, nil
}