instagram

package
v0.5.21 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EndpointExchangeAccessTokenURL 交换用户授权的 access_token 的请求地址
	EndpointExchangeAccessTokenURL = "https://api.instagram.com/oauth/access_token"
	// EndpointUserInfoURL 获取用户信息的请求地址
	EndpointUserInfoURL = "https://graph.instagram.com/me"
)
View Source
const (
	OAuthUrlIdentifierKey = "instagram.oauth2.url.identifier.%s"
)

Variables

This section is empty.

Functions

func GetOAuthURLIdentifierKey

func GetOAuthURLIdentifierKey(state string) string

GetOAuthURLIdentifierKey 获取 OAuth URL 标识键

Types

type ExchangeAccessTokenResp

type ExchangeAccessTokenResp struct {
	AccessToken string `json:"access_token"`
	UserID      string `json:"user_id"`
}

type GetUserResp

type GetUserResp struct {
	ID       string `json:"id"`
	UserName string `json:"username"`
}

type OAuth

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

func New

func New(opts ...Option) *OAuth

func (*OAuth) BuildAuthPageURL

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

BuildAuthPageURL 构建授权页面 URL

func (*OAuth) ExchangeAccessToken

func (oauth *OAuth) ExchangeAccessToken(code string) (string, error)

ExchangeAccessToken 交换用户授权的 access_token

func (*OAuth) GetUserInfoByAccessToken

func (oauth *OAuth) GetUserInfoByAccessToken(accessToken string) (*GetUserResp, error)

GetUserInfoByAccessToken 通过 access_token 获取用户信息

func (*OAuth) HandleOAuth2ByAPPAuthToken

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

HandleOAuth2ByAPPAuthToken 处理 APP 授权登录

func (*OAuth) HandleOAuth2ByAuthCode

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

func (*OAuth) Provide

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

type Option

type Option func(o *Options)

func WithClientID

func WithClientID(clientID 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 {
	ClientID     string
	ClientSecret string
	RedirectURL  string
	Scope        []string
}

type User

type User struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

Jump to

Keyboard shortcuts

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