tokens

package
v0.0.0-...-d727afa Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package tokens defines queries to obtain and authorize access tokens for the Twitter API.

Index

Constants

View Source
const UsePIN = "oob"

UsePIN is used as the callback in an authorization ticket request to request "out-of-band" or PIN based verification.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessOpts

type AccessOpts struct{}

AccessOpts provides optional values for an access-token request. A nil *AccessOpts provides empty values for all fields.

type AccessQuery

type AccessQuery struct {
	*jape.Request
}

An AccessQuery is a query for an access token.

func GetAccess

func GetAccess(c auth.Config, reqToken, verifier string, opts *AccessOpts) AccessQuery

GetAccess constructs a query to obtain an access token from the given request token and verifier.

This query does not require c.AccessToken or c.AccessTokenSecret.

API: oauth/access_token

func (AccessQuery) Invoke

func (a AccessQuery) Invoke(ctx context.Context, cli *twitter.Client) (AccessToken, error)

Invoke issues the query and returns the access Token.

type AccessToken

type AccessToken struct {
	Token
	UserID   string
	Username string
}

An AccessToken is a Token with optional user identification data.

type BearerOpts

type BearerOpts struct{}

BearerOpts provides optional values for a bearer-token request. A nil *BearerOpts provides empty values for all fields.

type BearerQuery

type BearerQuery struct {
	*jape.Request
	// contains filtered or unexported fields
}

A BearerQuery is a query for an OAuth 2 bearer token.

func GetBearer

func GetBearer(c auth.Config, opts *BearerOpts) BearerQuery

GetBearer constructs a query to obtain an OAuth2 bearer token.

Bearer token requests are authenticated using c.APIKey and c.APISecret. This query does not require c.AccessToken or c.AccessTokenSecret.

API: oauth2/token

func (BearerQuery) Invoke

func (q BearerQuery) Invoke(ctx context.Context, cli *twitter.Client) (Token, error)

Invoke issues the query and returns the bearer token.

type InvalidateQuery

type InvalidateQuery struct {
	*jape.Request
	// contains filtered or unexported fields
}

InvalidateQuery is a query for a token invalidation request.

func InvalidateAccess

func InvalidateAccess(c auth.Config, token, secret string) InvalidateQuery

InvalidateAccess constructs a query to invalidate an access token. This query does not use c.AccessToken or c.AccessTokenSecret.

API: oauth/invalidate_token

func InvalidateBearer

func InvalidateBearer(c auth.Config, bearerToken string) InvalidateQuery

InvalidateBearer constructs a query to invalidate a bearer token.

This query requires c.AccessToken and c.AccessTokenSecret to be the access token of the owner of the bearer token.

API: oauth2/invalidate_token

func (InvalidateQuery) Invoke

func (q InvalidateQuery) Invoke(ctx context.Context, cli *twitter.Client) (string, error)

Invoke issues the query and returns the invalidated token.

type RequestOpts

type RequestOpts struct {
	AccessType string // access override; "read" or "write"
}

RequestOpts provides optional values for a ticket-granting request. A nil *RequestOpts provides empty values for all fields.

type RequestQuery

type RequestQuery struct {
	*jape.Request
	// contains filtered or unexported fields
}

A RequestQuery is a query for an authorization ticket.

func GetRequest

func GetRequest(c auth.Config, callback string, opts *RequestOpts) RequestQuery

GetRequest constructs a query to obtain an authorization request ticket for the specified callback URL. Pass UsePIN for the callback to use PIN based verification.

This query requires c.AccessToken and c.AccessTokenSecret to be set to the application's own credentials.

API: oauth/request_token

func (RequestQuery) Invoke

func (q RequestQuery) Invoke(ctx context.Context, cli *twitter.Client) (Token, error)

Invoke issues the query to the given client and returns the request Token.

type Token

type Token struct {
	Key    string
	Secret string
}

A Token carries a token key and its corresponding secret.

Jump to

Keyboard shortcuts

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