social

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	APIEndpointAuthBase  = "https://access.line.me"
	APIEndpointAuthorize = "/oauth2/v2.1/authorize"

	APIEndpointBase                 = "https://api.line.me"
	APIEndpointToken                = "/oauth2/v2.1/token"
	APIEndpointTokenVerify          = "/oauth2/v2.1/verify"
	APIEndpointRevokeToken          = "/oauth2/v2.1/revoke"
	APIEndpointGetUserProfile       = "/v2/profile"
	APIEndpointGetFriendshipStratus = "/friendship/v1/status"
)

APIEndpoint constants

Variables

View Source
var (
	ErrInvalidSignature = errors.New("invalid signature")
)

errors

Functions

func GenerateCodeVerifier added in v0.4.0

func GenerateCodeVerifier(length int) string

GenerateCodeVerifier: Generate code verifier (length 43~128) for PKCE.

func GenerateNonce added in v0.2.0

func GenerateNonce() string

func PkceChallenge added in v0.4.0

func PkceChallenge(verifier string) string

PkceChallenge: base64-URL-encoded SHA256 hash of verifier, per rfc 7636

Types

type APIError

type APIError struct {
	Code     int
	Response *ErrorResponse
}

APIError type

func (*APIError) Error

func (e *APIError) Error() string

Error method

type AuthRequestOptions

type AuthRequestOptions struct {
	Nonce     string
	Prompt    string
	MaxAge    int
	UILocales string
	BotPrompt string
}

type BasicResponse

type BasicResponse struct {
}

BasicResponse type

type Client

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

Client type

func New

func New(channelID, channelSecret string, options ...ClientOption) (*Client, error)

New returns a new bot client instance.

func (*Client) GetAccessToken

func (client *Client) GetAccessToken(redirectURL, code string) *GetAccessTokenCall

GetAcceessToken: Issues access token.

func (*Client) GetFriendshipStatus

func (client *Client) GetFriendshipStatus(accessToken string) *GetFriendshipStatusCall

GetFriendshipStatus: Gets the friendship status of the user and the bot linked to your LINE Login channel. Note: Requires an access token with the profile scope. For more information, see Making an authorization request and Scopes. Note: You must have a bot linked with your channel. For more information, see Linking a bot with your LINE Login channel.

func (*Client) GetPKCEWebLoinURL added in v0.4.0

func (client *Client) GetPKCEWebLoinURL(redirectURL string, state string, scope string, codeChallenge string, options AuthRequestOptions) string

GetPKCEWebLoinURL - LINE LOGIN 2.1 get LINE Login authorization request URL by PKCE

func (*Client) GetUserProfile

func (client *Client) GetUserProfile(accessToken string) *GetUserProfileCall

GetUserProfile: Gets a user's display name, profile image, and status message. Note: Requires an access token with the profile scope. For more information, see Making an authorization request and Scopes.

func (*Client) GetWebLoinURL

func (client *Client) GetWebLoinURL(redirectURL string, state string, scope string, options AuthRequestOptions) string

GetWebLoinURL - LINE LOGIN 2.1 get LINE Login authorization request URL

func (*Client) RefreshToken

func (client *Client) RefreshToken(refreshToken string) *RefreshTokenCall

Refresh Token: Gets a new access token using a refresh token. Refresh tokens are returned with the access token when the user authorizes your app. Note: This is the reference for the v2.1 endpoint. For the v2 reference, see Refresh access token v2. Note: Cannot be used to refresh channel access tokens which are used for the Messaging API.

func (*Client) RevokeToken

func (client *Client) RevokeToken(accessToken string) *RevokeTokenCall

RevokeToken: Invalidates the access token. Note: This is the reference for the v2.1 endpoint. For the v2 reference, see Revoke access token v2. Note: Cannot be used to invalidate channel access tokens which are used for the Messaging API.

func (*Client) TokenVerify

func (client *Client) TokenVerify(accessToken string) *TokenVerifyCall

TokenVerify: Verifies the access token. Note: This is the reference for the v2.1 endpoint. For the v2 reference, see Verify access token v2 (https://developers.line.biz/en/reference/social-api-v2/#verify-access-token)

type ClientOption

type ClientOption func(*Client) error

ClientOption type

func WithEndpointBase

func WithEndpointBase(endpointBase string) ClientOption

WithEndpointBase function

func WithHTTPClient

func WithHTTPClient(c *http.Client) ClientOption

WithHTTPClient function

type ErrorResponse

type ErrorResponse struct {
	Message string                `json:"message"`
	Details []errorResponseDetail `json:"details"`
}

ErrorResponse type

type GetAccessTokenCall

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

GetAccessTokenCall type

func (*GetAccessTokenCall) Do

func (call *GetAccessTokenCall) Do() (*TokenResponse, error)

Do method

func (*GetAccessTokenCall) WithContext

func (call *GetAccessTokenCall) WithContext(ctx context.Context) *GetAccessTokenCall

WithContext method

type GetAccessTokenPKCECall added in v0.4.0

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

GetAccessTokenPKCECall type

func (*GetAccessTokenPKCECall) Do added in v0.4.0

Do method

func (*GetAccessTokenPKCECall) WithContext added in v0.4.0

WithContext method

type GetFriendshipStatusCall

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

GetUserProfileCall type

func (*GetFriendshipStatusCall) Do

Do method

func (*GetFriendshipStatusCall) WithContext

WithContext method

type GetFriendshipStatusResponse

type GetFriendshipStatusResponse struct {
	// FriendFlag: true if the user has added the bot as a friend and has not blocked the bot. Otherwise, false.
	FriendFlag bool `json:"friendFlag"`
}

GetFriendshipStatusResponse type

type GetUserProfileCall

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

GetUserProfileCall type

func (*GetUserProfileCall) Do

Do method

func (*GetUserProfileCall) WithContext

func (call *GetUserProfileCall) WithContext(ctx context.Context) *GetUserProfileCall

WithContext method

type GetUserProfileResponse

type GetUserProfileResponse struct {
	// UserID: Identifier of the user
	UserID string `json:"userId"`

	// DisplayName: User's display name
	DisplayName string `json:"displayName"`

	// PictureURL: Profile image URL. "https" image URL. Not included in the response if the user doesn't have a profile image.
	PictureURL string `json:"pictureUrl"`

	//StatusMessage: User's status message. Not included in the response if the user doesn't have a status message.
	StatusMessage string `json:"statusMessage"`
}

GetUserProfileResponse type

type Payload

type Payload struct {
	Iss      string   `json:"iss"`
	Sub      string   `json:"sub"`
	Aud      string   `json:"aud"`
	Exp      int      `json:"exp"`
	Iat      int      `json:"iat"`
	AuthTime int      `json:"auth_time"`
	Nonce    string   `json:"nonce"`
	Amr      []string `json:"amr"`
	Name     string   `json:"name"`
	Picture  string   `json:"picture"`
	Email    string   `json:"email"`
}

type RefreshTokenCall

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

RefreshTokenCall type

func (*RefreshTokenCall) Do

Do method

func (*RefreshTokenCall) WithContext

func (call *RefreshTokenCall) WithContext(ctx context.Context) *RefreshTokenCall

WithContext method

type RevokeTokenCall

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

RefreshTokenCall type

func (*RevokeTokenCall) Do

func (call *RevokeTokenCall) Do() (*BasicResponse, error)

Do method

func (*RevokeTokenCall) WithContext

func (call *RevokeTokenCall) WithContext(ctx context.Context) *RevokeTokenCall

WithContext method

type TokenRefreshResponse

type TokenRefreshResponse struct {
	// TokenType: Bearer
	TokenType string `json:"token_type"`

	// Scope: Permissions granted by the user. For more information, see Scopes.
	//profile: Permission to get the user's profile information.
	//openid: Used to retrieve an ID token. For more information, see ID tokens.
	//email: Permission to get the user's email address. openid must be specified at the same time. For more information, see ID tokens.
	Scope string `json:"scope"`

	// AccessToken: Access token. Valid for 30 days.
	AccessToken string `json:"access_token"`

	// ExpiresIn: Amount of time in seconds until the access token expires
	ExpiresIn int `json:"expires_in"`

	// RefreshToken: Which token you want to refresh.
	//Token used to get a new access token. Valid up until 10 days after the access token expires.
	RefreshToken string `json:"refresh_token"`
}

Token refresh type

type TokenResponse

type TokenResponse struct {
	// AccessToken: Access token. Valid for 30 days.
	AccessToken string `json:"access_token"`

	// ExpiresIn: Amount of time in seconds until the access token expires
	ExpiresIn int `json:"expires_in"`

	// IDToken: JSON Web Token (JWT) that includes information about the user.
	//This field is returned only if openid is specified in the scope. For more information, see ID tokens.
	IDToken string `json:"id_token"`

	// RefreshToken: Which token you want to refresh.
	//Token used to get a new access token. Valid up until 10 days after the access token expires.
	RefreshToken string `json:"refresh_token"`

	// Scope: Permissions granted by the user. For more information, see Scopes.
	//profile: Permission to get the user's profile information.
	//openid: Used to retrieve an ID token. For more information, see ID tokens.
	//email: Permission to get the user's email address. openid must be specified at the same time. For more information, see ID tokens.
	Scope string `json:"scope"`

	// TokenType: Bearer
	TokenType string `json:"token_type"`
}

TokenResponse type

func (TokenResponse) DecodePayload

func (t TokenResponse) DecodePayload(channelID string) (*Payload, error)

DecodePayload : decode payload result.

type TokenVerifyCall

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

Client type

func (*TokenVerifyCall) Do

func (call *TokenVerifyCall) Do() (*TokenVerifyResponse, error)

Do method

func (*TokenVerifyCall) WithContext

func (call *TokenVerifyCall) WithContext(ctx context.Context) *TokenVerifyCall

WithContext method

type TokenVerifyResponse

type TokenVerifyResponse struct {
	Scope     string `json:"scope"`
	ClientID  string `json:"client_id"`
	ExpiresIn int    `json:"expires_in"`
}

Token verification reponse

type UserProfileResponse

type UserProfileResponse struct {
	UserID        string `json:"userId"`
	DisplayName   string `json:"displayName"`
	PictureURL    string `json:"pictureUrl"`
	StatusMessage string `json:"statusMessage"`
}

UserProfileResponse type

Jump to

Keyboard shortcuts

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