Shopify 통합을 개발하기 시작했습니다. 통합하려는 의 앱에는 사용자 계정별로 다른 하위 도메인이 있으므로 은 각 oauth 연결 요청에 대해 다른 콜백 도메인으로 리디렉션해야합니다. 지금까지 Shopify 권한 부여 URL로 리디렉션하여 사용자가 자신의 계정에 대한 액세스 권한을 부여 할 수있게했습니다. 모든 내가 ( Shopify의 관리자 페이지에서 설정) 응용 프로그램의 URL을 설정하는 시도Shopify를 응용 프로그램 URL의 하위 도메인으로 리디렉션하는 방법은 무엇입니까?
https://SHOP_NAME.myshopify.com/admin/oauth/authorize?client_id=MY_CLIENT_ID&scope=read_order&redirect_uri=SUBDOMAIN.MYAPP.com
:
{"error":"invalid_request",
"error_description":"The redirect_uri and application url must have matching hosts"}
의 URL 형식이다 : 그러나, 나는의 오류 응답이 를 얻을 수
: 나는 작업을 얻을 수 있습니다, 그러나http://MYAPP.com
http://.MYAPP.com
http://*.MYAPP.com
: 이들의하면 같은 오류가 나타납니다
http://SUBDOMAIN.MYAPP.com
난 그냥 예를 들어, 쿼리 문자열에서 정보를 받아, 하위 도메인에 리디렉션 엔드 포인트를 만들 수 있습니다
:이 문제를 해결하지만 것보다는 Shopify API 그 것이다
callback.MYAPP.com?subdomain=SUBDOMAIN
Shopify 페이지를 내 앱에 링크를 만들고 싶습니다. 따라서 이러한 수준의 간접 지정을 꾸준히 구축하지 않아도됩니다. (이 현재 개발 이후) (나도 거기에 를 동일한 작업을 수행해야 할 것 같은 응용 프로그램 링크 관리 페이지에서 찾고, 보이는,하지만.)
나는 비표준 TLD를 사용하고 . 그래서 MYAPP.com을 넣은 곳은 정말로 oh.dev입니다. .com 호스트 파일을 편집하여 .com을 사용해 보았습니다. 결과가 있습니다.
누구나 Shopify가 callback_url이라는 하위 도메인을 허용하는 방법을 알고 있습니까? 나는 명백한 것을 놓쳤는가?
또한(require '[com.twinql.clojure.http :as http] '[clojure.contrib.logging :as log])
(defn consumer []
{:key "1234567890"
:secret "1234567890abcde"})
(defn shopify-config [shop-name]
{:request-token-url (str "https://" shop-name ".myshopify.com/admin/oauth/authorize")
:authorise-url (str "https://" shop-name ".myshopify.com/admin/oauth/authorize")
:access-token-url (str "https://" shop-name ".myshopify.com/admin/oauth/access_token")
:api-endpoint-url (str "https://" shop-name ".myshopify.com")})
(defn get-redirect-url [shop-name callback-url]
(let [{consumer-token :key consumer-token-secret :secret} (consumer)]
(str (-> shop-name shopify-config :request-token-url)
"?client_id=" consumer-token
"&scope=read_orders,read_products,read_customers"
"&redirect_uri=" callback-url)))
(defn get-access-credentials [verifier shop-name]
(let [{:keys [key secret]} (consumer)
response (http/post (-> shop-name shopify-config :access-token-url)
:as :json
:query {"client_id" key
"client_secret" secret
"code" verifier})]
(log/debug (str "response from getting access credentials from shopify : " response))
{:access-token (-> response :content :access_token)
:consumer-key key
:consumer-secret secret}))
(def methods {:get http/get
:post http/post
:delete http/delete
:put http/put})
(defn- make-request [method shop-name url token params]
(let [response (method (str (-> shop-name shopify-config :api-endpoint-url) url)
:as :json
:query params
:headers {"X-Shopify-Access-Token" token})]
(if (-> response :code (= 200))
(:content response)
(do
(log/error (str "Error in shopify request : " response))
(throw (Err. {:handle :shopify-request-error
:response response}))))))
(defn get-products [shop-name token page]
(make-request (:get methods) shop-name "/admin/products.json" token {:page page :limit 200}))
의 사용자로부터 가게 이름 같은 것들을 얻을 몇 가지 코드가, 저장합니다를 DB에 등 :
는 여기에 몇 가지 Clojure의 코드입니다. 따라서 우리는 기본적으로 get-redirect-url을 호출하여 사용자가 shopify하도록 리디렉션하고 에게 권한을 승인하도록 요청합니다. 다음 제공된 전화를 걸고받을-액세스 자격 증명 코드를 취
http://customer1.oh.dev/integrations/shopify/1/callback
: 우리는 Shopify에 전달하는 콜백 URL이 뭔가 같다. 주변 코드는 우리가 반환하는 액세스 토큰 등을 저장합니다. 그런 다음 & shop-name을 검색 한 후 get-products를 호출 할 다른 사용자 조치가 있습니다.
몇 가지 코드를 게시 할 수 있지만 HTTP 호출 만하고 있으며 제대로 작동하지 않고 작동하지 않는다는 차이점은 응용 프로그램 URL 설정의 하위 도메인 설정뿐입니다. 또한 개발 중이기 때문에 비표준 TLD를 사용합니다. 그게 문제의 일부인지 궁금하네요. – l0st3d
일부 코드가 게시되었습니다. 그것이 의미가 없거나 너무 많이 누락되어 있는지 물어보십시오. – l0st3d
파트너 영역 내에서 애플리케이션 URL을 oh.dev로 등록 했습니까? –