tiktok

package
v0.5.25 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserScopeBasic        = "user.info.basic"
	UserScopeArtistRead   = "artist.certification.read"
	UserScopeArtistUpdate = "artist.certification.update"
	UserScopeUserProfile  = "user.info.profile"
	UserScopeUserStats    = "user.info.stats"
)

UserScope 用户授权范围

View Source
const (
	OAuthUrlIdentifierKey = "google.oauth2.url.identifier.%s"
)

Variables

This section is empty.

Functions

func GetOAuthURLIdentifierKey added in v0.5.17

func GetOAuthURLIdentifierKey(state string) string

Types

type Error added in v0.5.1

type Error struct {
	/* 错误类别 */
	Code string `json:"code"`
	/* 错误描述 */
	Message string `json:"message"`
	/* LogId */
	LogId string `json:"log_id"`
}

type FetchAccessTokenReq added in v0.5.1

type FetchAccessTokenReq struct {
	/* required 客户端 Key 在tiktok开发者平台查看 */
	ClientKey string `json:"client_key"`
	/* required 客户端 Secret 在tiktok开发者平台查看 */
	ClientSecret string `json:"client_secret"`
	/* required 授权码 */
	Code string `json:"code"`
	/* required 授权类型 固定为:authorization_code */
	GrantType string `json:"grant_type"`
	/* required 回调的重定向地址 */
	RedirectURL string `json:"redirect_uri"`
	/* 仅适用于移动和桌面应用程序。代码验证器用于在 PKCE 授权流程中生成代码质询。 */
	CodeVerifier string `json:"code_verifier"`
}

FetchAccessTokenReq 获取 access_token 请求参数

type FetchAccessTokenResp added in v0.5.1

type FetchAccessTokenResp struct {
	/* 用户授权的唯一标识 */
	OpenId string `json:"open_id"`
	/* 用户授权的数据范围 */
	Scope string `json:"scope"`
	/* 用户授权的访问令牌 */
	AccessToken string `json:"access_token"`
	/* 访问令牌的有效期,单位为秒 */
	ExpiresIn int64 `json:"expires_in"`
	/* 用户授权的刷新令牌, 首次前发后365天有效 */
	RefreshToken string `json:"refresh_token"`
	/* 刷新令牌的有效期,单位为秒 */
	RefreshExpiresIn int64 `json:"refresh_expires_in"`
	/* 用户授权的令牌类型 固定为:Bearer */
	TokenType string `json:"token_type"`

	/* 以下为请求错误响应内容 */
	/* 错误类型 */
	Error string `json:"error"`
	/* 错误描述 */
	ErrorDescription string `json:"error_description"`
	/* LogId */
	LogId string `json:"log_id"`
}

FetchAccessTokenResp 获取 access_token 响应参数

type OAuth

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

func New

func New(opts ...Option) *OAuth

New 创建一个 OAuth 实例

func (*OAuth) BuildAuthPageURL added in v0.5.17

func (oauth *OAuth) BuildAuthPageURL() (string, error)

BuildAuthPageURL 构建授权页面 URL

func (*OAuth) FetchAccessToken added in v0.5.1

func (oauth *OAuth) FetchAccessToken(code, codeVerifier string) (*FetchAccessTokenResp, error)

func (*OAuth) GetUserInfo added in v0.5.1

func (oauth *OAuth) GetUserInfo(accessToken string, fields []string) (*UserInfoResp, error)

func (*OAuth) HandleOAuth2ByAPPAuthToken added in v0.5.17

func (oauth *OAuth) HandleOAuth2ByAPPAuthToken(token string) (*plugin.OAuthUser, error)

HandleOAuth2ByAPPAuthToken 处理 APP 授权登录

func (*OAuth) HandleOAuth2ByAuthCode added in v0.5.17

func (oauth *OAuth) HandleOAuth2ByAuthCode(code *plugin.VerifyCode) (*plugin.OAuthUser, error)

func (*OAuth) Provide

func (oauth *OAuth) Provide(ctx context.Context) any

func (*OAuth) RefreshAccessToken added in v0.5.1

func (oauth *OAuth) RefreshAccessToken(refreshToken string) (*FetchAccessTokenResp, error)

func (*OAuth) RevokeToken added in v0.5.1

func (oauth *OAuth) RevokeToken(accessToken string) error

type Option

type Option func(o *Options)

func WithClientKey added in v0.5.1

func WithClientKey(clientKey string) Option

func WithClientSecret

func WithClientSecret(clientSecret string) Option

func WithRedirectURL

func WithRedirectURL(redirectURL string) Option

func WithScope

func WithScope(scope []string) Option

type Options

type Options struct {
	ClientKey    string
	ClientSecret string
	RedirectURL  string
	Scope        []string
}

type UserInfoResp added in v0.5.1

type UserInfoResp struct {
	/* 用户信息 */
	Data map[string]UserObject `json:"data"`
	/* 错误信息 */
	Error Error `json:"error"`
}

type UserObject added in v0.5.1

type UserObject struct {
	/* 用户在当前应用中的唯一标识 */
	OpenId string `json:"open_id"`
	/* 用户在当前开发者账号下所有应用的唯一标识 */
	UnionId string `json:"union_id"`
	/* 用户头像地址 */
	AvatarURL string `json:"avatar_url"`
	/* 用户头像地址(100x100) */
	AvatarURL100 string `json:"avatar_url_100"`
	/* 最高分辨率的用户头像地址 */
	AvatarLargeURL string `json:"avatar_large_url"`
	/* 显示名称 */
	DisplayName string `json:"display_name"`
	/* 用户个人简介 */
	BioDescription string `json:"bio_description"`
	/* 用户TikTok个人资料页面链接 */
	ProfileDeepLink string `json:"profile_deep_link"`
	/* 用户是否已完成TikTok验证 */
	IsVerified bool `json:"is_verified"`
	/* 用户昵称 */
	Username string `json:"username"`
	/* 用户的关注者数量 */
	FollowerCount int64 `json:"follower_count"`
	/* 用户的关注的账户数量 */
	FollowingCount int64 `json:"following_count"`
	/* 用户所有视频的点赞数量 */
	LikesCount int64 `json:"likes_count"`
	/* 用户公开发布的视频总数 */
	VideoCount int64 `json:"video_count"`
}

Jump to

Keyboard shortcuts

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