twitter

package
v0.0.0-...-305dc57 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ScopeOfflineAccess = "offline.access"
	ScopeTweetWrite    = "tweet.write"
	ScopeUsersRead     = "users.read"
	ScopeTweetRead     = "tweet.read"
)
View Source
var Endpoint = oauth2.Endpoint{
	AuthStyle: oauth2.AuthStyleInHeader,
	AuthURL:   "https://twitter.com/i/oauth2/authorize",
	TokenURL:  "https://api.twitter.com/2/oauth2/token",
}

Functions

func BeginTwitterAuth

func BeginTwitterAuth() (state string, pkceCodeVerifier string, redirect string, err error)

func DefaultScopes

func DefaultScopes() []string

func FinishTwitterAuth

func FinishTwitterAuth(ctx context.Context, state, prevState, pkceCodeVerifier, code string) (*oauth2.Token, error)

func OAuthConfig

func OAuthConfig() *oauth2.Config

Types

type Client

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

func NewClient

func NewClient(ctx context.Context, tok *oauth2.Token) *Client

func (*Client) GetMe

func (c *Client) GetMe(ctx context.Context) (*GetMeResponse, error)

type GetMeResponse

type GetMeResponse struct {
	Data struct {
		ID       string `json:"id"`
		Name     string `json:"name"`
		Username string `json:"username"`
	} `json:"data"`
}

GetMeResponse is the structure of the response from https://api.twitter.com/2/users/me

{
  "data": {
    "id": "2244994945",
    "name": "TwitterDev",
    "username": "Twitter Dev"
  }
}

Jump to

Keyboard shortcuts

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