How to set X-Shopify-Storefront-Access-Token header on Mobile Buy SDK, IOS

Highlighted
New Member
4 0 0

Hello. I am sure this has been solved before. However, I could not find the right answer. Your help will be greated appreciated.

I am trying to read products from ios to my "private" store for testing purpose. When a store is private, one could use X-Shopify-Storefront-Access-Token header. However, I could not find how to set the header in the ios code. Here is my code. Please help.

 

1. Create Client:

static let sharedClient = Graph.Client(
                                    shopDomain: "fancy-handbags.myshopify.com",
                                    apiKey:     "cd5b3b9ce48c5b88bb2777b0f57e4182"
                                )

 2. Query

        let query = Storefront.buildQuery { $0

            .products(first:100) {$0
                .edges {$0
                    .node {$0
                        .description()
                        .id()
                        .title()
                  }
                }
              }
        }

Execution

        let task = client.queryGraphWith(query) { response, error in
            if ((response) != nil) {
                <process success>
            } else if (error != nil) {
                <process failure>
            }
            else{
                print("Gosh! No")
            }
        }
        task.resume()

 

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
491 97 88

Hi @_SC_ 

 

Can you attempt using the Storefront Access Token vs. the API key? 

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


0 Likes