core

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigInterface

type ConfigInterface interface {
	SetScopes(scopes []string)
	SetState(state ...string)
	GetAuthUrl() string
	UserFromCode(ctx context.Context, code string) (*User, error)
}

type ErrorInterface

type ErrorInterface interface {
	Contains() bool
	Code() gcode.Code
}

type Response

type Response struct {
	Status     string
	StatusCode int
	Header     http.Header
	Body       []byte
}

Response is the struct for client requst response.

func (*Response) ReadAll

func (r *Response) ReadAll() []byte

ReadAll return byte array from reposne body

func (*Response) ReadAllString

func (r *Response) ReadAllString() string

ReadAll to String

type Token

type Token struct {
	// AccessToken is the token that authorizes and authenticates
	// the requests.
	AccessToken string `json:"access_token"`

	// TokenType is the type of token.
	// The Type method returns either this or "Bearer", the default.
	TokenType string `json:"token_type,omitempty"`

	// RefreshToken is a token that's used by the application
	// (as opposed to the user) to refresh the access token
	// if it expires.
	RefreshToken string `json:"refresh_token,omitempty"`

	// Expiry is the optional expiration time of the access token.
	//
	// If zero, TokenSource implementations will reuse the same
	// token forever and RefreshToken or equivalent
	// mechanisms for that TokenSource will not be used.
	Expiry gtime.Time `json:"expiry,omitempty"`
}

type User

type User struct {
	ID       string
	Name     string
	NickName string
	Avatar   string
	Email    string
	Raw      *gjson.Json
	Error    ErrorInterface
}

func (*User) ContainsError

func (u *User) ContainsError() bool

Error contains

func (*User) GetAccessToken

func (u *User) GetAccessToken() string

GetAccessToken

func (*User) GetAvatar

func (u *User) GetAvatar() string

GetAvatar

func (*User) GetEmail

func (u *User) GetEmail() string

GetEmail

func (*User) GetErrorCode

func (u *User) GetErrorCode() gcode.Code

func (*User) GetExpiresIn

func (u *User) GetExpiresIn() int

GetExpiresIn

func (*User) GetID

func (u *User) GetID() string

GetID

func (*User) GetName

func (u *User) GetName() string

GetName

func (*User) GetNickName

func (u *User) GetNickName() string

GetNickName

func (*User) GetRaw

func (u *User) GetRaw() *gjson.Json

GetRaw return *gjson.Json @see github.com/gogf/gf/encoding/gjson

func (*User) GetRefreshToken

func (u *User) GetRefreshToken() string

GetRefreshToken

type UserInterface

type UserInterface interface {
	// Get oauth user ID,when oauth finished
	GetID() string

	// Get oauth user name, sometimes name is equal nickname
	GetName() string

	// Get oauth user nickname, see above GetName()
	GetNickName() string

	// Get oauth user Avatar
	GetAvatar() string

	// Get oauth user email
	GetEmail() string

	// The raw data return like json parsed to gjson.Json,
	// see gjson.Json https://pkg.golang.ir/github.com/gogf/gf/v2/encoding/gjson
	GetRaw() *gjson.Json

	// Contains error the oauth server return
	ContainsError() bool

	// Get error code
	// see gcode.Code https://pkg.golang.ir/github.com/gogf/gf/v2/errors/gcode
	GetErrorCode() gcode.Code

	// Get and Set token, token expires
	GetAccessToken() string
	GetRefreshToken() string
	GetExpiresIn() int
}

Jump to

Keyboard shortcuts

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