Documentation ¶
Index ¶
- Constants
- Variables
- type Authorizer
- type Client
- func (c *Client) GetProfile(ctx context.Context, accessToken string) (*LINEProfile, error)
- func (c *Client) VerifyAccessToken(ctx context.Context, accessToken string) (*VerifyAccessTokenResponse, error)
- func (c *Client) VerifyIDToken(ctx context.Context, idToken, userid, nonce string) (*IDTokenData, error)
- type IDTokenData
- type LINEProfile
- type VerifyAccessTokenResponse
Constants ¶
const ( HeaderKeyLINEUserID = "LINEUserID" HeaderKeyLINEDisplayName = "LINEDisplayName" HeaderKeyLINEPictureURL = "LINEPictureURL" HeaderKeyLINEEmail = "LINEEmail" HeaderKeyLINEStatusMessage = "LINEStatusMessage" )
Variables ¶
var ( // ErrBadRequest 400 Bad Request リクエストに問題があります。リクエストパラメータとJSONの形式を確認してください。 ErrBadRequest = errors.New("400 Bad Request") ErrUnauthorized = errors.New("401 Unauthorized") // ErrForbidden 403 Forbidden APIを使用する権限がありません。ご契約中のプランやアカウントに付与されている権限を確認してください。 ErrForbidden = errors.New("403 Forbidden") // ErrTooManyRequests 429 Too Many Requests リクエスト頻度をレート制限内に抑えてください。 ErrTooManyRequests = errors.New("429 Too Many Requests") // ErrInternalServerError 500 Internal Server Error APIサーバーの一時的なエラーです。 ErrInternalServerError = errors.New("500 Internal Server Error") )
Functions ¶
This section is empty.
Types ¶
type Authorizer ¶
type Authorizer struct {
// contains filtered or unexported fields
}
Authorizer is a clientset of LINE Auth API
func NewAuthorizer ¶
func NewAuthorizer(lineClient *Client, log logr.Logger) *Authorizer
NewAuthorizer return new Authorizer
func (*Authorizer) VerifyAccessTokenMiddleware ¶
func (a *Authorizer) VerifyAccessTokenMiddleware(next http.Handler) http.Handler
VerifyAccessTokenMiddleware is a middleware of http handler Obtain access token from authorization header and verify it upstream The authorized LINE user info is set in request headers "LINEUserID", "LINEDisplayName", "LINEPictureURL", "LINEStatusMessage"
func (*Authorizer) VerifyIDTokenMiddleware ¶
func (a *Authorizer) VerifyIDTokenMiddleware(next http.Handler) http.Handler
VerifyIDTokenMiddleware is a middleware of http handler Obtain id token from authorization header and verify it upstream The authorized LINE user info is set in request headers "LINEUserID", "LINEDisplayName", "LINEPictureURL", "LINEEmail"
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an http client access to LINE Login API
func NewClient ¶ added in v0.0.2
NewClient returns LINE loging API Client. "id" is LINE Client ID a.k.a LINE Channel ID.
func (*Client) GetProfile ¶
GetProfile is a function to call get-user-profile API https://developers.line.biz/ja/reference/line-login-v2/#get-profile-response
func (*Client) VerifyAccessToken ¶
func (c *Client) VerifyAccessToken(ctx context.Context, accessToken string) (*VerifyAccessTokenResponse, error)
VerifyAccessToken is a function to call verify-access-token API https://developers.line.biz/ja/reference/line-login/#verify-access-token
func (*Client) VerifyIDToken ¶
func (c *Client) VerifyIDToken(ctx context.Context, idToken, userid, nonce string) (*IDTokenData, error)
VerifyIDToken is a function to call verify-id-token. UserID and Nonce can be empty when not use. https://developers.line.biz/ja/reference/line-login/#verify-id-token
type IDTokenData ¶
type IDTokenData struct { Iss string `json:"iss"` Sub string `json:"sub"` Aud string `json:"aud"` Exp string `json:"exp"` Nonce string `json:"nonce,omitempty"` Amr []string `json:"amr,omitempty"` Name string `json:"name,omitempty"` Picutre string `json:"picture,omitempty"` Email string `json:"email,omitempty"` }
IDTokenData is the response json struct of verify-id-token API. https://developers.line.biz/ja/reference/line-login/#verify-id-token
type LINEProfile ¶
type LINEProfile struct { UserID string `json:"userId"` DisplayName string `json:"displayName"` PictureURL string `json:"pictureUrl"` StatusMessage string `json:"statusMessage"` }
LINEProfile is the response json struct of get-user-profile API https://developers.line.biz/ja/reference/line-login-v2/#get-profile-response
type VerifyAccessTokenResponse ¶
type VerifyAccessTokenResponse struct { Scope string `json:"scope"` ClientID string `json:"client_id"` ExpiresIn int `json:"expires_in"` }
VerifyAccessTokenResponse is the response json struct of verify-access-token API. https://developers.line.biz/ja/reference/line-login/#verify-access-token