Skip to content

Commit

Permalink
fix: use channel access token
Browse files Browse the repository at this point in the history
  • Loading branch information
kyong0612 committed Jan 2, 2024
1 parent 37be353 commit eecf963
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
6 changes: 4 additions & 2 deletions .clouddeploy/run-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ spec:
env:
- name: ENV
value: production
- name: LINE_CHANNEL_TOKEN
value: dummy # from-param: ${line_token}
- name: LINE_CHANNEL_SECRET
value: dummy # from-param: ${line_secret_token}
- name: LINE_CHANNEL_ACCESS_TOKEN
value: dummy # from-param: ${line_access_token}
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
LINE_CHANNEL_TOKEN=YOUR_CHANNEL_TOKEN
LINE_CHANNEL_SECRET=YOUR_CHANNEL_SECRET
LINE_CHANNEL_ACCESS_TOKEN=YOUR_CHANNEL_ACCESS_TOKEN
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ jobs:
region: "${{ env.REGION }}"
skaffold_file: ".clouddeploy/skaffold.yaml"
deploy_parameters: |-
line_token=${{ secrets.LINE_TOKEN }}
line_secret_token=${{ secrets.LINE_CHANNEL_SECRET }}
line_access_token=${{ secrets.LINE_CHANNEL_ACCESS_TOKEN }}
- name: "Report Cloud Deploy release"
run: |-
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ deploy.release:
--project=kyong0612-lab \
--region=asia-northeast1 \
--delivery-pipeline=fitness-support \
--deploy-parameters="line_token=$(LINE_CHANNEL_TOKEN)"
--deploy-parameters="line_secret_token=$(LINE_CHANNEL_SECRET),line_access_token=$(LINE_CHANNEL_ACCESS_TOKEN)"
7 changes: 4 additions & 3 deletions infra/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
)

type config struct {
ENV string `env:"ENV" envDefault:"local"`
Port int `env:"PORT" envDefault:"8080"`
LINEChannelToken string `env:"LINE_CHANNEL_TOKEN,required"`
ENV string `env:"ENV" envDefault:"local"`
Port int `env:"PORT" envDefault:"8080"`
LINEChannelSecret string `env:"LINE_CHANNEL_SECRET,required"`
LINEChannelAccessToken string `env:"LINE_CHANNEL_ACCESS_TOKEN,required"`
}

var cfg config
Expand Down
2 changes: 1 addition & 1 deletion infra/line/clinet.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type client struct {

func NewClient() (Client, error) {
bot, err := messaging_api.NewMessagingApiAPI(
config.Get().LINEChannelToken,
config.Get().LINEChannelAccessToken,
)
if err != nil {
return nil, errors.Wrap(err, "failed to create line client")
Expand Down
2 changes: 1 addition & 1 deletion infra/line/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func ParseWebhookRequest(ctx context.Context, req *http.Request) ([]MessageEvent
)

cb, err := webhook.ParseRequest(
config.Get().LINEChannelToken,
config.Get().LINEChannelSecret,
req,
)
if err != nil {
Expand Down

0 comments on commit eecf963

Please sign in to comment.