helper

package module
v0.0.0-...-67703da Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

line-oauth2-helper

Build Status codecov GoDoc Go Report Card

Introduction

Helper to generate LINE JSON Web Token (JWT) for LINE OAuth2 v2.1.

Install

% go get github.com/clsung/line-oauth2-helper/cmd/line_jwt

Usage

Command line

% line_jwt -file ${LINE_PRIVATEKEY_FILE} -channel_id ${CHANNEL_ID}

or

% line_jwt -channel_id ${CHANNEL_ID} < ${LINE_PRIVATEKEY_FILE}

Docker

Pull the image:

% docker pull clsung/line-oauth2-helper:stable

Web version

then run the following

% docker run -ti -p 8080:8080 clsung/line-oauth2-helper:stable

and connect to http://localhost:8080/

Command line

% docker run -i clsung/line-oauth2-helper:stable line_jwt -channel_id ${CHANNEL_ID} < ${LINE_PRIVATEKEY_FILE}

Documentation

Index

Constants

View Source
const (
	AudienceLINE       = "https://api.line.me/"
	DefaultExpiry      = 30 * time.Minute
	DefaultTokenExpire = 2592000 // 30 Day
)

default values

Variables

This section is empty.

Functions

This section is empty.

Types

type Helper

type Helper struct {

	//Expiry is the JWT expiry duration from now.
	Expiry time.Duration
	// TokenExp denotes the valid expiration time for the channel access token in seconds.
	TokenExpire int
	// contains filtered or unexported fields
}

Helper helps to generate JWT for line

func New

func New(channelID string) *Helper

New helper

func (*Helper) GetLineJWT

func (h *Helper) GetLineJWT(r io.Reader) (string, error)

GetLineJWT reads from io.Reader and return JWT or error

func (*Helper) GetLineJWTFromFile

func (h *Helper) GetLineJWTFromFile(filePath string) (string, error)

GetLineJWTFromFile reads from file and return JWT or error

func (*Helper) WithExpiry

func (h *Helper) WithExpiry(expiry time.Duration) *Helper

WithExpiry set JWT valid duration

func (*Helper) WithTokenExpire

func (h *Helper) WithTokenExpire(tokenExp int) *Helper

WithTokenExpire set token expire in seconds

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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