haibei/pkg/jwtx/token.go
2025-06-19 10:33:58 +08:00

35 lines
634 B
Go

package jwtx
import (
jsoniter "github.com/json-iterator/go"
)
type TokenInfo interface {
GetAccessToken() string
GetTokenType() string
GetExpiresAt() int64
EncodeToJSON() ([]byte, error)
}
type tokenInfo struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
ExpiresAt int64 `json:"expires_at"`
}
func (t *tokenInfo) GetAccessToken() string {
return t.AccessToken
}
func (t *tokenInfo) GetTokenType() string {
return t.TokenType
}
func (t *tokenInfo) GetExpiresAt() int64 {
return t.ExpiresAt
}
func (t *tokenInfo) EncodeToJSON() ([]byte, error) {
return jsoniter.Marshal(t)
}