# Fetch Customer data in custom UI extension

**URL:** <https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947>\
**Category:** Extensions\
**Tags:** customer-account-ext\
**Created:** [May 8, 2025, 2:50pm UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947 "2025-05-08T14:50:05Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Muthu\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Muthu\_Kumar](https://community.shopify.dev/u/Muthu_Kumar)\
**Post date:** [May 8, 2025, 2:50pm UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/1 "2025-05-08T14:50:05Z")

</div>

I’m developing a Shopify custom UI extension app and encountering an issue where the app scopes (read\_products, read\_customers) are not being recognized by Shopify, even though I’ve defined them in my configuration files. This is causing an “Access denied for customer field. Required access: read\_customers access scope” error when querying customer data in GraphiQL.  
I have received → Access denied for customer field. Required access: `read_customers` access scope.

How to use HTML elements and CSS styling in a custom UI extension. I have tried using a simple “div” element. When I’m running that code locally. I have received “unsupported component: div”

---

<div class="post-metadata">

**Author:** ![Alan\_G](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/alan_g/32/5321_2.png) [@Alan\_G](https://community.shopify.dev/u/Alan_G)\
**Post date:** [May 8, 2025, 5:39pm UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/2 "2025-05-08T17:39:25Z")

</div>

Hey @Muthu_Kumar 👋 - happy to see if I can help out with this. Are you using our [Remix app template here](https://shopify.dev/docs/apps/build)? Generally, you’d want to define your access scopes in the app’s config .toml file: [App configuration](https://shopify.dev/docs/apps/build/cli-for-apps/app-configuration)

If the app has installed already on the shop and you’re getting that “required access” error, it’s likely that the access scopes didn’t pass correctly. I’d double check to see what access scopes your app has to check which ones were passed when the app was installed.

If you added any scopes after the initial installation, you do need to navigate back to your app’s page in the Shopify admin in order to trigger a reauthorization so that the new scopes get added, so it’s possible that may be what’s happening here.

For your HTML/CSS question, with UI extensions we do limit what components can be used in extensions, there’s a bit more info on this here in our old forums: [Re: Can't use html in post puchase extension? - Shopify Community](https://community.shopify.com/c/shopify-discussions/can-t-use-html-in-post-puchase-extension/m-p/2041921/highlight/true#M356313)

Hope this helps - let me know if I can clarify anything on my end here 🙂

---

<div class="post-metadata">

**Author:** ![Muthu\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Muthu\_Kumar](https://community.shopify.dev/u/Muthu_Kumar)\
**Post date:** [May 9, 2025, 2:43am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/3 "2025-05-09T02:43:32Z")

</div>

Im using Customer account UI extensions and tried Remix app template also. I have received the same problem.

For the shopify.app.toml file, I have added the scope like →   
scopes = “read\_products,read\_customers”

Again I have create and installed the app in shopify dev-store. Now I can see that scopes values in Shopify partners-\> my app-\> API Access.  
Required scopes

- read\_customers
- read\_products

But then i can’t access the customer data.

const {query, authenticatedAccount} = useApi();  
const customer= useSubscription(authenticatedAccount.customer);  
I tried this, but i get only customer’s ID, not other data.

For the HTML/CSS → You mean, I can’t use the HTML elements directly on that Customer account UI extension?

---

<div class="post-metadata">

**Author:** ![curzey](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/curzey/32/7190_2.png) [@curzey](https://community.shopify.dev/u/curzey)\
**Post date:** [May 9, 2025, 5:22am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/4 "2025-05-09T05:22:35Z")

</div>

> [@Muthu\_Kumar](#):
>
> authenticatedAccount

[`authenticatedAccount`](https://shopify.dev/docs/api/customer-account-ui-extensions/2025-04/apis/authenticated-account) only returns the customer id, so that makes sense.

 ![image](https://global.discourse-cdn.com/shopifycommunity/original/2X/f/f0d8410e76f18cd1f9d0d1d67386f2adfe88337b.jpeg)

Depending on your target, I think you need the use [Customer Account API reference](https://shopify.dev/docs/api/customer).

Example

```javascript
const exampleCustomerQuery = {
  query: `query {
    customer {
      id
      firstName
      metafields(identifiers: [{namespace: "custom", key: "some_key"}]) {
        type
        value
        key
      }
    }
  }`
};

fetch("shopify://customer-account/api/2025-01/graphql.json", {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify(exampleCustomerQuery),
}).then(response => response.json())
  .then(data => {       
    console.log({data});
  })
  .catch(error => console.error('Error fetching customer data:', error));

```

---

<div class="post-metadata">

**Author:** ![curzey](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/curzey/32/7190_2.png) [@curzey](https://community.shopify.dev/u/curzey)\
**Post date:** [May 9, 2025, 5:23am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/5 "2025-05-09T05:23:58Z")

</div>

> [@Muthu\_Kumar](#):
>
> For the HTML/CSS → You mean, I can’t use the HTML elements directly on that Customer account UI extension?

Correct - you need to use the predefined components, which you can find here: [Customer-account-ui-extensions components](https://shopify.dev/docs/api/customer-account-ui-extensions/2025-04/components)

A bit more on that here: [Customer account UI extensions](https://shopify.dev/docs/api/customer-account-ui-extensions/2025-04#ui-components)

---

<div class="post-metadata">

**Author:** ![Muthu\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Muthu\_Kumar](https://community.shopify.dev/u/Muthu_Kumar)\
**Post date:** [May 9, 2025, 7:12am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/6 "2025-05-09T07:12:13Z")

</div>

Thank you for your reply, @curzey.

fetch(“shopify://customer-account/api/2025-01/graphql.json”, {  
method: ‘POST’,  
headers: { ‘Content-Type’: ‘application/json’ },  
body: JSON.stringify(exampleCustomerQuery),  
}).then(response =\> response.json())  
.then(data =\> {  
console.log({data});  
})  
.catch(error =\> console.error(‘Error fetching customer data:’, error))

I have implemented this method and was able to successfully retrieve the `first_name` and `last_name` fields. However, I was unable to fetch the other field values. The response returned the error: 'Field must have selection.

---

<div class="post-metadata">

**Author:** ![curzey](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/curzey/32/7190_2.png) [@curzey](https://community.shopify.dev/u/curzey)\
**Post date:** [May 9, 2025, 7:45am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/7 "2025-05-09T07:45:03Z")

</div>

Hi again, I’m glad it worked.

My best bet would be to read the linked documentation carefully. Some fields has more levels.

What fields do you have problems with?

---

<div class="post-metadata">

**Author:** ![Muthu\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Muthu\_Kumar](https://community.shopify.dev/u/Muthu_Kumar)\
**Post date:** [May 9, 2025, 8:35am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/8 "2025-05-09T08:35:46Z")

</div>

Hi @curzey

I couldn’t fetch the email, phone, address, and orders fields.

---

<div class="post-metadata">

**Author:** ![curzey](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/curzey/32/7190_2.png) [@curzey](https://community.shopify.dev/u/curzey)\
**Post date:** [May 9, 2025, 9:07am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/9 "2025-05-09T09:07:35Z")

</div>

Can you share some code

---

<div class="post-metadata">

**Author:** ![Muthu\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Muthu\_Kumar](https://community.shopify.dev/u/Muthu_Kumar)\
**Post date:** [May 9, 2025, 9:17am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/10 "2025-05-09T09:17:06Z")

</div>

Now I could fetch email and phone number. How to fetch orders list data and Do I need to get any permissions to fetch the order data?

```auto
const exampleCustomerQuery = {
  query: `query {
              customer {
                id
                firstName
                lastName
                phoneNumber{
                     phoneNumber
                }
                emailAddress{
                    emailAddress
                }
                metafields(identifiers: [{namespace: "custom", key: "some_key"}]) {
                  type
                  value
                  key
                }
       orders(first: 5) {
        edges {
          node {
            id
            name
            totalPrice {
              amount
              currencyCode
            }
          }
        }
      }
    }
  }`,
};
fetch("shopify://customer-account/api/2025-01/graphql.json", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(exampleCustomerQuery),
})
  .then((response) => response.json())
  .then((data) => {
    console.log("hhey", { data });
  })
  .catch((error) => console.error("Error fetching customer data:", error));

```

---

<div class="post-metadata">

**Author:** ![curzey](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/curzey/32/7190_2.png) [@curzey](https://community.shopify.dev/u/curzey)\
**Post date:** [May 9, 2025, 9:50am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/11 "2025-05-09T09:50:04Z")

</div>

I think you need more permissions to get the customer orders. Theres a [Connection to orders on the Customer object](https://shopify.dev/docs/api/customer/latest/objects/Customer#connection-orders) so your query looks correct.

What errors do you get in the Network tab?

Read through the permissions for protected data here: [Work with protected customer data](https://shopify.dev/docs/apps/launch/protected-customer-data#protected-customer-data-api-types-and-resources).

You can also try with the [`customer_read_customer` and `customer_read_orders`](https://shopify.dev/docs/api/usage/access-scopes#customer-access-scopes) access scopes, to see if they make a change. Just remember to re-open your app and accept the new access scopes your app will request.

---

<div class="post-metadata">

**Author:** ![Muthu\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Muthu\_Kumar](https://community.shopify.dev/u/Muthu_Kumar)\
**Post date:** [May 10, 2025, 10:35am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/12 "2025-05-10T10:35:45Z")

</div>

Thank you @curzey

I was able to successfully fetch both order and customer details.

Now, I have another question regarding the UI. In your previous response, you mentioned that we cannot use standard HTML and CSS within the UI extension.

However, I would like to implement a customizable interface on that page — for example, a tabbed layout with Tab 1 displaying the user list and Tab 2 showing the order list.

So, what would be the recommended approach to implement such a UI?  
Can I create a custom tabbed interface within the existing framework, or am I limited to using only the predefined Customer Account UI extensions?

---

<div class="post-metadata">

**Author:** ![curzey](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/curzey/32/7190_2.png) [@curzey](https://community.shopify.dev/u/curzey)\
**Post date:** [May 10, 2025, 4:14pm UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/13 "2025-05-10T16:14:26Z")

</div>

That’s great!

You’re limited to the existing components linked to earlier. But you can create a tabbed layout it.

---

<div class="post-metadata">

**Author:** ![Muthu\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Muthu\_Kumar](https://community.shopify.dev/u/Muthu_Kumar)\
**Post date:** [May 12, 2025, 6:58am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/14 "2025-05-12T06:58:05Z")

</div>

Yeah, got it @curzey.

I’m currently integrating the Razorpay payment method with my Shopify store. When I click the ‘Install’ button, I’m redirected to the Razorpay dashboard. I’ve completed all the required steps — including account creation, basic details, and KYC verification — except for the ‘Collect Payments’ step.

However, I selected ‘Test Mode’ at that step and received my Razorpay Key ID and Secret, which I’ve downloaded. Despite this, Shopify still displays the ‘Install Razorpay’ prompt on the payments page, as if it hasn’t been installed.

Could you please help me understand why Razorpay isn’t showing as installed in Shopify even after completing these steps?

---

<div class="post-metadata">

**Author:** ![curzey](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/curzey/32/7190_2.png) [@curzey](https://community.shopify.dev/u/curzey)\
**Post date:** [May 12, 2025, 7:10am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/15 "2025-05-12T07:10:48Z")

</div>

If this is not related to the topic, please create it as a new. Bear in mind, that this is a forum.

Also, it doesn’t seem applicable for the context. Sounds like you should create it as an app ticket / razorpay ticket / Shopify ticket.

---

<div class="post-metadata">

**Author:** ![Muthu\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Muthu\_Kumar](https://community.shopify.dev/u/Muthu_Kumar)\
**Post date:** [May 12, 2025, 7:34am UTC](https://community.shopify.dev/t/fetch-customer-data-in-custom-ui-extension/14947/16 "2025-05-12T07:34:10Z")

</div>

Thank you @curzey for your support…
