Hello I am using Remix app template with App Theme Extension and App Proxy . For some reason I am unable to authorized any Admin API call when my embedded app component are being pressed.
Here is my endpoint file
export const action = async({request}) => {
// param will get pass in like the following
// data = {product_id: 123}
switch (request.method) {
case "PUT": {
/* handle "PUT" */
// get the body data
const data = await request.json()
console.log(data)
let query = `
mutation MetafieldSet($metafields: [MetafieldsSetInput!]!) {
metafieldsSet(metafields: $metafields) {
metafields {
key
namespace
value
createdAt
updatedAt
}
userErrors {
field
message
code
}
}
}
`
let input = {
"metafields": [
{
"key": "wishlist",
"namespace": "CP_app",
"ownerId": "gid://shopify/Customer/7396475044125",
"type": "json",
"value": "{}"
}
]
}
const { admin } = await authenticate.public.appProxy(request);
const response = await admin.graphql(query, input );
console.log(response)
// append the data to the json metafield to a specific customer (likely by their id)
// namespace: CP_app
// key: wishlist
// console.log("request data", response)
return json({"message": "item added"})
}
default: {
return json({"message": "HTTP METHOD not suppported"})
}
}
}
Here is my Theme APP Extension test button file
{% schema %}
{
"name": "Test Button",
"target": "section"
}
{% endschema %}
Here is the output Log
Anyone got an ideal why when the button being pressed the graphQL query is rejected due to authorization. but I’ve print out my admin object which contain my API keys and my API secret key
