Open1

【Shopify】AWS eventbridgeを使ってみる

Eiji Saito | UnReact Inc.Eiji Saito | UnReact Inc.

参考記事

https://docs.aws.amazon.com/ja_jp/connect/latest/adminguide/integrate-customer-profiles-shopify.html

https://dev.classmethod.jp/articles/shopify-with-eventbridge/

つまずいたところ

  • codeの取得
  • アドレス(ARN)の値

基本的に記事通りすれば問題ない。

codeの取得

記事の中で下記リンクからcodeの値を取得するときがある。

このときは、Invarid OAuth callback になるけど、その時のcodeクエリの値を取得して、
実行する。

https://reterior-whole-sale.myshopify.com/admin/oauth/authorize?client_id=e7e9bc9af5197245fedf412e8f58b0f4&scope=write_products,write_customers,write_draft_orders&redirect_uri=https://reterior-whole-sale.herokuapp.com/auth/callback

curl -X POST -H "Content-Type: application/json" https://reterior-whole-sale.myshopify.com/admin/oauth/access_token -d "$(cat <<EOS
{
    "client_id": "e7e9bc9af5197245fedf412e8f58b0f4",
    "client_secret": "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",
    "code": "17e90bb6cd3b609e73f7e43b21d34735"                         
}
EOS
)" | jq .

ARNの場所

ARNがありすぎてどれかわからんやった。
パートナーイベントソースの「パートナーイベントソースのARN」をいれて実行する。

curl -X POST -H "Content-Type: application/json" -H "X-Shopify-Access-Token: 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" https://reterior-whole-sale.myshopify.com/admin/api/2021-04/webhooks.json -d "$(cat <<EOS
{
  "webhook": {
    "topic": "products/update",
    "address": "arn:aws:events:ap-northeast-1::event-source/aws.partner/shopify.com/6453355/shopify-devio-app",                            
    "format": "json"
  }
}  
EOS      
)" | jq .

出力

Shopifyストアで商品を登録したら、商品の登録情報を取得できた。