connect

package
v2.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package connect provides a client for the Webull Connect API, an OAuth 2.0 flow for third-party applications. The authorization-code step is performed by redirecting the user's browser to the URL returned by Client.AuthorizationURL; the code is then exchanged for tokens with Client.CreateToken.

Reference: https://developer.webull.com/apis/docs/connect-api/about-connect-api

Index

Constants

View Source
const (

	// ResponseTypeCode is the OAuth 2.0 authorization-code response type.
	ResponseTypeCode = "code"
	// GrantTypeAuthorizationCode exchanges an authorization code for tokens.
	GrantTypeAuthorizationCode = "authorization_code"
	// GrantTypeRefreshToken exchanges a refresh token for new tokens.
	GrantTypeRefreshToken = "refresh_token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationParams

type AuthorizationParams struct {
	// ResponseType is the OAuth response type. Empty means [ResponseTypeCode].
	ResponseType string
	// ClientID is the OAuth client identifier. Required.
	ClientID string
	// Scope is the requested scope. Required.
	Scope string
	// State is an opaque anti-CSRF value echoed back by the server. Required.
	State string
	// RedirectURI is the registered callback URI. Required.
	RedirectURI string
}

AuthorizationParams parameterizes Client.AuthorizationURL.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the Webull Connect (OAuth) API client.

func New

func New(c *client.Client) *Client

New binds a Connect API client to an existing core client. The core client is owned by the caller and is not closed by Client.Close.

func (*Client) AuthorizationURL

func (c *Client) AuthorizationURL(p AuthorizationParams) string

AuthorizationURL builds the browser URL that starts the OAuth 2.0 authorization-code flow. The user is redirected here to grant access; the server then redirects back to RedirectURI with the authorization code.

func (*Client) Close

func (c *Client) Close() error

Close releases resources held by the Connect client. The underlying core client is not closed.

func (*Client) Core

func (c *Client) Core() *client.Client

Core returns the underlying core client.

func (*Client) CreateToken

func (c *Client) CreateToken(ctx context.Context, req TokenRequest) (*Token, error)

CreateToken exchanges an authorization code or refresh token for an access token via the signed Connect API.

type Token

type Token struct {
	AccessToken      string `json:"access_token"`
	TokenType        string `json:"token_type"`
	ExpiresIn        string `json:"expires_in"`
	RefreshExpiresIn string `json:"rt_expires_in"`
	RefreshToken     string `json:"refresh_token"`
	CreatedAt        string `json:"created_at"`
	IdentityID       string `json:"identity_id"`
}

Token is an OAuth 2.0 token pair returned by Client.CreateToken.

type TokenRequest

type TokenRequest struct {
	// GrantType is [GrantTypeAuthorizationCode] or [GrantTypeRefreshToken].
	// Required.
	GrantType string
	// Code is the authorization code, required for the authorization-code grant.
	Code string
	// RedirectURI is the callback URI, required for the authorization-code grant.
	RedirectURI string
	// RefreshToken is the refresh token, required for the refresh-token grant.
	RefreshToken string
}

TokenRequest parameterizes Client.CreateToken.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL