shopify_rest v1.0.2 Shopify.REST

Link to this section Summary

Functions

Send a request to Shopify.

Ensures an HTTP query string passes HMAC verification.

Verifies the Shopify HMAC signature.

Link to this section Types

Link to this type

http_headers_t()

http_headers_t() :: [{String.t(), String.t()}]
Link to this type

http_method_t()

http_method_t() :: :delete | :get | :post | :put
Link to this type

response_t()

response_t() ::
  {:ok, Shopify.REST.Response.t()} | {:error, Shopify.REST.Response.t() | any()}

Link to this section Functions

Link to this function

request(operation, config)

Send a request to Shopify.

Link to this function

verify_hmac(query, shared_secret)

verify_hmac(String.t(), String.t()) :: {:ok, String.t()} | {:error, String.t()}

Ensures an HTTP query string passes HMAC verification.

See verify_hmac/3 for more details.

Example

query = "code=0907a61c0c8d55e99db179b68161bc00&hmac=700e2dadb827fcc8609e9d5ce208b2e9cdaab9df07390d2cbca10d7c328fc4bf&shop=some-shop.myshopify.com&state=0.6784241404160823&timestamp=1337178173"
shared_secret = "hush"

{:ok, hmac} = Shopify.OAuth.verify_hmac(query, shared_secret)
Link to this function

verify_hmac(hmac, message, shared_secret)

verify_hmac(String.t(), String.t(), String.t()) ::
  {:ok, String.t()} | {:error, String.t()}

Verifies the Shopify HMAC signature.

This function will compute an SHA256 HMAC digest based on the provided message and shared_secret. The digest is then compared to the hmac signature. If they match, verification has passed. Otherwise verification has failed.

Example

hmac = "700e2dadb827fcc8609e9d5ce208b2e9cdaab9df07390d2cbca10d7c328fc4bf"
message = "code=0907a61c0c8d55e99db179b68161bc00&shop=some-shop.myshopify.com&timestamp=1337178173"
shared_secret = "hush"

{:ok, hmac} = Shopify.HMAC.verify(hmac, message, shared_secret)