// Create a new OAuth client.
509814
func (s *Service) OAuthClientCreate(ctx context.Context, o OAuthClientCreateOpts) (*OAuthClient, error) {
	var oauthClient OAuthClient
	return &oauthClient, s.Post(ctx, &oauthClient, fmt.Sprintf("/oauth/clients"), o)
}
564954
func NewDefaultAuthClient(conn io.ReadWriteCloser) *rpc.Client {
	return rpc.NewClientWithCodec(NewDefaultAuthClientCodec(conn))
}
146008
func (a *Account) CreateOAuthClient(client *OAuthClient) (c *OAuthClient, err error) {
	err = a.post(a.auth.WithScope(scope.Clients), "/api/v2/clients", client, &c)
	return c, err
}
1199460
func NewClient(
	accessToken string,
	clientID string,
	apiURL string,
	logger logger.Logger,
) wl.Client {
	return &oauthClient{
		apiURL:      apiURL,
		accessToken: accessToken,
		clientID:    clientID,
		logger:      logger,
	}
}
573374
func NewAuthClient(applicationKey string, token *string) (*Client, error) {
	rr := NewBearerTokenTransport(applicationKey, token)
	client := &http.Client{
		Transport: rr,
	}
	return NewCustomClient(client)
}
1184659
func NewClient(accessKeyId, accessKeySecret string) *Client {
	client := &Client{}
	client.Init(END_POINT, VERSION, accessKeyId, accessKeySecret)
	return client
}
779954
func NewClient(opts ClientOpts) *Client {
	if opts.HTTPClient == nil {
		opts.HTTPClient = &http.Client{}
	}

	return &Client{
		token:      opts.Token,
		baseURL:    opts.BaseURL,
		httpClient: opts.HTTPClient,
		userAgent:  opts.UserAgent,
	}
}
270260
func NewClient(uri string) Client {
	return &client{client: http.DefaultClient, base: uri}
}
448621
func newHTTPClient(config *Config) (*http.Client, APIResponse) {
	return config.Authentication.Authenticate(config)
}
61571
func NewAuthenticate(clientKey, secret, callbackURL string) *Provider {
	return New(clientKey, secret, callbackURL)
}
1017618
func (user *User) OAuthHTTPClient() *http.Client {

	ps, _ := user.protectedSettings()

	if ps == nil {
		return nil
	}

	if ps.OAuthToken == "" {
		return nil
	}

	if user.ctx.Service().DefaultOAuth2 != nil {
		ts := user.ctx.OAuthProvider().OAuth2Client(user.ctx).TokenSource(oauth2.NoContext, &oauth2.Token{AccessToken: ps.OAuthToken, RefreshToken: ps.OAuthRefreshToken, Expiry: *ps.OAuthExpireDate, TokenType: "Bearer"})
		if ps.OAuthExpireDate != nil && ps.OAuthExpireDate.Before(time.Now().Add(time.Second*5)) {
			token, err := ts.Token()
			if err != nil {
				if strings.Contains(err.Error(), "revoked") || strings.Contains(err.Error(), "invalid_grant") {
					ps.OAuthToken = ""
					ps.OAuthExpireDate = nil
					user.saveProtectedSettings()
					//todo: provide revoked callback
				}
				user.ctx.Log().WithError(err).Error("OAuth token refresh failed")
				return nil
			}

			if token != nil {
				ps.OAuthToken = token.AccessToken
				if token.RefreshToken != "" {
					ps.OAuthRefreshToken = token.RefreshToken
				}
				ps.OAuthExpireDate = &token.Expiry
				user.saveProtectedSettings()
			}
		}
		return oauth2.NewClient(oauth2.NoContext, ts)
	} else if user.ctx.Service().DefaultOAuth1 != nil {
		//todo make a correct httpclient
		return http.DefaultClient
	}
	return nil
}
1263404
func NewClient(url, token string) *Client {
	return &Client{
		url:         strings.TrimSuffix(url, "/"),
		accessToken: token,
		client:      &http.Client{},
	}
}
573832
func New() *Client {
	cookieJar, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
	return createClient(&http.Client{Jar: cookieJar})
}
421621
func newClient(server string, opts ...client.ClientOption) *client.Client {
	if server == "" {
		return client.NewOrFail(opts...)
	}
	cl := client.NewOrFail(append(opts[:len(opts):cap(opts)], client.OptionServer(server))...)
	if err := cl.SetupAuth(); err != nil {
		log.Fatalf("Could not setup auth for connecting to %v: %v", server, err)
	}
	return cl
}
178080
func NewClient(authToken string) *Client {
	baseURL, err := url.Parse(defaultBaseURL)
	if err != nil {
		panic(err)
	}

	c := &Client{
		authToken: authToken,
		BaseURL:   baseURL,
		client:    http.DefaultClient,
	}
	c.Room = &RoomService{client: c}
	c.User = &UserService{client: c}
	c.Emoticon = &EmoticonService{client: c}
	return c
}
682381
func NewClient(user, pass, base string) *Client {
	return &Client{
		ID:          user,
		Token:       pass,
		Client:      defaultHttpClient,
		Base:        base,
		UploadType:  JSON,
		ErrorParser: DefaultErrorParser,
	}
}
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)
}