line-social-sdk-go: github.com/kkdai/line-social-sdk-go Index | Files

package social

import "github.com/kkdai/line-social-sdk-go"

Index

Package Files

client.go doc.go error.go response.go social.go tool.go version.go

Constants

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

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

APIEndpoint constants

Variables

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

errors

func GenerateNounce Uses

func GenerateNounce() string

type APIError Uses

type APIError struct {
    Code     int
    Response *ErrorResponse
}

APIError type

func (*APIError) Error Uses

func (e *APIError) Error() string

Error method

type BasicResponse Uses

type BasicResponse struct {
}

BasicResponse type

type Client Uses

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

Client type

func New Uses

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

New returns a new bot client instance.

func (*Client) GetAccessToken Uses

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

GetAcceessToken: Issues access token.

func (*Client) GetFriendshipStatus Uses

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) GetUserProfile Uses

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 Uses

func (client *Client) GetWebLoinURL(redirectURL, state, scope, nounce, chatbotPrompt string) string

GetWebLoinURL - LINE LOGIN 2.1 get LINE Login URL

func (*Client) RefreshToken Uses

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 Uses

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 Uses

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 Uses

type ClientOption func(*Client) error

ClientOption type

func WithEndpointBase Uses

func WithEndpointBase(endpointBase string) ClientOption

WithEndpointBase function

func WithHTTPClient Uses

func WithHTTPClient(c *http.Client) ClientOption

WithHTTPClient function

type ErrorResponse Uses

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

ErrorResponse type

type GetAccessTokenCall Uses

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

GetAccessTokenCall type

func (*GetAccessTokenCall) Do Uses

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

Do method

func (*GetAccessTokenCall) WithContext Uses

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

WithContext method

type GetFriendshipStatusCall Uses

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

GetUserProfileCall type

func (*GetFriendshipStatusCall) Do Uses

func (call *GetFriendshipStatusCall) Do() (*GetFriendshipStatusResponse, error)

Do method

func (*GetFriendshipStatusCall) WithContext Uses

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

WithContext method

type GetFriendshipStatusResponse Uses

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 Uses

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

GetUserProfileCall type

func (*GetUserProfileCall) Do Uses

func (call *GetUserProfileCall) Do() (*GetUserProfileResponse, error)

Do method

func (*GetUserProfileCall) WithContext Uses

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

WithContext method

type GetUserProfileResponse Uses

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 Uses

type Payload struct {
    Iss     string `json:"iss"`
    Sub     string `json:"sub"`
    Aud     string `json:"aud"`
    Exp     int    `json:"exp"`
    Iat     int    `json:"iat"`
    Nonce   string `json:"nonce"`
    Name    string `json:"name"`
    Picture string `json:"picture"`
}

type RefreshTokenCall Uses

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

RefreshTokenCall type

func (*RefreshTokenCall) Do Uses

func (call *RefreshTokenCall) Do() (*TokenRefreshResponse, error)

Do method

func (*RefreshTokenCall) WithContext Uses

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

WithContext method

type RevokeTokenCall Uses

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

RefreshTokenCall type

func (*RevokeTokenCall) Do Uses

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

Do method

func (*RevokeTokenCall) WithContext Uses

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

WithContext method

type TokenRefreshResponse Uses

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 Uses

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 Uses

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

type TokenVerifyCall Uses

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

Client type

func (*TokenVerifyCall) Do Uses

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

Do method

func (*TokenVerifyCall) WithContext Uses

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

WithContext method

type TokenVerifyResponse Uses

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

Token verification reponse

type UserProfileResponse Uses

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

UserProfileResponse type

Package social imports 15 packages (graph) and is imported by 1 packages. Updated 2019-03-24. Refresh now. Tools for package owners.