Get customer email

I am trying to access customer email from customer-account-ui-extension via the following

const getCustomerEmailQuery = {
      query: `query {
        customer {
          emailAddress {
            emailAddress
          }
        }
      }`
    }
    fetch('shopify://customer-account/api/2024-10/graphql.json', {

and am experiencing: Access denied for customer field. Required access: customer_read_customers access scope.

which I went ahead and included in toml

[access_scopes]
scopes = "customer_read_customers"

but it’s not working? Is this the best way to approach getting logged in user email?

Hi!

Which toml file did you add it to? shopify.app.toml or shopify.extension.toml?

If it doesnt show in the app backend dashboard, it seems like it’s either missing from the correct toml file, or you forgot to deploy the app with shopify app deploy.

Thanks curzey. I have applied the change to shopify.extension.toml and I have not deployed. This is in dev store (i.e., shopify app dev) so I thought permissions would be easier. Is shopify app deploy necessary?

Edit: after updating extension.toml and deploying, nothing is changed sadly. Both .toml files have access_scopes defined but shopify app deploy does nothing. I wonder if it is because of the info displayed when deploying:

New version created, but not released. 
Network access must be requested and approved in order for this extension to be published
1 Like

I tracked it down. Needed to grant network access in partners.shopify.com in addition to tweaking shopify.app.toml and deploying

Sadly this hasn’t solved the problem. I’m still getting
Access denied for customer field. Required access: customer_read_customers access scope.

1 Like

The step that I was missing was to re-install the app :man_facepalming:. Need to make sure to click install when previewing so that new changes are available. With that the request succeeds.

1 Like

Hi @devin

You can try this

npm run deploy

1 Like

Glad you found it. Have been in a likely situation before. I just forgot to actually open the app and accept new access scopes to finally grant it :sweat_smile: