tiktok

package module
v0.0.0-...-e33276a Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2021 License: MIT Imports: 7 Imported by: 0

README

tiktok-oauth2

GoDoc codecov goreportcard

A package to add support for TikTok OAuth 2.0 on top of the Golang's package (https://github.com/golang/oauth2)

You can find the official TikTok documentation here

Install

$ go get github.com/chanioxaris/tiktok-oauth2

Available functions
  • NewConfig() Create a new TikTok oauth2 config
  • ConfigExchange() Convert an oauth2 config into an oauth2 token
  • RefreshToken() Refresh the access token
  • RevokeAccess() Revoke the access token
  • RetrieveUserInfo() Retrieve basic information of a TikTok user
Helper functions
  • OpenIDFromToken() Retrieve the extra field open_id from an oauth2 token.
  • ScopeFromToken() Retrieve the extra field scope from an oauth2 token.
  • RefreshExpiresInFromToken() Retrieve the extra field refresh_expires_in from an oauth2 token.
License

tiktok-oauth2 is MIT licensed.

Documentation

Overview

Package tiktok provides support for making OAuth2 authorized and authenticated HTTP requests on TikTok platform.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigExchange

func ConfigExchange(ctx context.Context, config *oauth2.Config, code string) (*oauth2.Token, error)

ConfigExchange converts an oauth2 config and authorization code into an oauth2 token.

func NewConfig

func NewConfig(clientID, clientSecret, redirectURL string, scopes ...string) (*oauth2.Config, error)

NewConfig returns a new TikTok oauth2 config based on provided arguments.

func OpenIDFromToken

func OpenIDFromToken(token *oauth2.Token) (string, error)

OpenIDFromToken is a helper function to retrieve 'open_id' extra field from an oauth2 token.

func RefreshExpiresInFromToken

func RefreshExpiresInFromToken(token *oauth2.Token) (int64, error)

RefreshExpiresInFromToken is a helper function to retrieve 'refresh_expires_in' extra field from an oauth2 token.

func RefreshToken

func RefreshToken(ctx context.Context, clientID, refreshToken string) (*oauth2.Token, error)

RefreshToken refreshes the access token of the user.

func RevokeAccess

func RevokeAccess(ctx context.Context, token *oauth2.Token) error

RevokeAccess revokes a user's access token.

func ScopeFromToken

func ScopeFromToken(token *oauth2.Token) (string, error)

ScopeFromToken is a helper function to retrieve 'scope' extra field from an oauth2 token.

Types

type UserInfo

type UserInfo struct {
	OpenID       string
	UnionID      string
	Avatar       string
	AvatarLarger string
	DisplayName  string
}

UserInfo holds some basic information of a given TikTok user.

func RetrieveUserInfo

func RetrieveUserInfo(ctx context.Context, token *oauth2.Token) (*UserInfo, error)

RetrieveUserInfo returns some basic information of a given TikTok user based on the open id.

Jump to

Keyboard shortcuts

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