Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello,
Like the title says there is something weird going on that I am not understanding.
Using a newly created user storefront access token (via customer email and password), when I try to query the customer object it comes back as null.
This is for a newly created account.
Anyone can help to try rubber duck and figure out if there something I am missing?
Hello,
To my understanding, you're dealing with 2 very different things that don't hold hands per se.
StorefrontAccessToken -This is set to give api access to your store. Checking orders, plugins, paid themes, that sort of thing.
For you to have "back stage access" to a store (or more appropriately for your plugin to have access to someone's store data) you have to give them access.
This access token is a part of that security handshake.
->more on that here: https://shopify.dev/docs/admin-api/rest/reference/access/storefrontaccesstoken
Customer -This object gets created once the customer has been logged in. -Yes, the customer must exist in the store to log in, but for this object to exist in liquid, you have to have the actual customer logged in.
->more on that here: https://shopify.dev/docs/themes/liquid/reference/objects/customer
Short answer: If you view the site without being logged in, the customer object won't be created. Calling it will not return a customer object. Hence nil.
Ahh okay I think you might have miss understood what I was trying to say or maybe I haven’t wrote this clearly.
Oookay.
If you post the code, it might've helped.
This is what I'm now guessing you're referring to.
I'm I close?
I have the same problem here and I did all process on Shopify GraphiQL App
I'm having the same problem. I'm creating a custom storefront using the shopify graphql. So on my login page when I log in the user using the customerAccessTokenCreate everything works fine:
```
In the result I don't get errors and I receive an access token. But when I try to use that access token for other queries, like getting the customer info:
query getCustomer($customerAccessToken: String!) {
customer(customerAccessToken: $customerAccessToken) {
acceptsMarketing
addresses(last: 5) {
edges {
node {
address1
address2
city
company
country
countryCodeV2
firstName
formatted
formattedArea
id
lastName
latitude
longitude
name
phone
province
provinceCode
zip
}
}
}
createdAt
displayName
email
firstName
id
lastName
numberOfOrders
phone
updatedAt
}
}
query variables:
{
"customerAccessToken": "theAccessTokenIJustCreated"
}
The result is always null, which is wrong, so can you please tell me what is happening here?
{
"data": {
"customer": null
}
}
Hello, @adrianiskandar and @diegojacomel ,
There's a lot to unpack here as far as how all this should work.
My suggestion which should cover all bases is:
1: find working example code and modify it.
2: That access token belongs to an account. Check which permissions it has on your store.
2.1: whatever the administrator of a store cannot see, the highest permission settings cannot see either.
2.2: a lot of your store data is more open than you think, such as variants and prices. Google "shopify store json"
3: shopify houses the userdata. Other than basic stuff, access is/should be out of the store owner's hands unless it is tied to an order.
4: look up the api you are using weather you're using php or something else to ping for the data. If the data is protected (used in system but not accessible outward) you cannot query it. You can try, but null data is what you will be given as a graceful crash.
This would be something I do for a fee, but I'm tied atm and can't give this the priority it deserves. However, if you get further and would like assistance, just reply to this thread.
-David_Weru
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025