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 ¶
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 ¶
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 ¶
Close releases resources held by the Connect client. The underlying core client is not closed.
func (*Client) CreateToken ¶
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.