Get Product ID for unpublished product

Shopify Partner
5 1 0

I’m trying to get the product id for a hidden product (toggle subscription) within the cart through an AJAX API call from the client. As a first step, I’m just trying to return all products. I’ve tried creating a private app using the Admin API, but I’m unable to get the Basic HTTP Authentication to return the needed JSON. It returns an HTML document with additional login links.  Any thoughts on what I may be doing wrong?


I understand what I'd be exposing, but access is read only for Products.  Building a public app seems unnecessary and likely overkill for this simple need, but I’m open to suggestions.




type: "GET",

url: "/admin/api/2019-10/products.json",

beforeSend: function(xhr) {

xhr.setRequestHeader("Authorization", "Basic " + "BASE64 encoded credentials")


success: function(json){










<a href="XXX ">Continue</a>



<script type="text/javascript">

window.location = "https:\/\/\/services\/login\/identity?.... =shop";






Replies 2 (2)

Shopify Expert
11196 226 2287

This is not the right way to get that info.


You're trying to make a AJAX call from the front end to the secure Admin API that requires authentication. Even if you passed over a key and password via AJAX you'd be doing that in plain text so this is a terrible ideal on many fronts. You're risking exposing those details to the public.


You should be creating some middleware that handles the authentication vs trying to go directly to the Admin API.


Why do you need the unpublished ID on the front end? That context could help in terms of talking about different approaches.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. ★
Shopify Partner
5 1 0
If a customer puts a product in their cart, I want to give them the option to toggle it as a subscription product. The subscription product is a hidden/unpublished product. To get the ID to add the subscription product, I need to look it up via the API. If the customer then wants the other (published) product, I have to look up the ID again.

Building an app or middleware seems like overkill. Does it make sense to hard code the IDs on the page?