Access Admin Api from public app's admin

sircameron
Tourist
6 0 1

I'm trying to access the list of themes and also to post an asset to the stores assets using the Admin API via my app's admin.
When attempting a call like:

`https://${shopOrigin}/admin/api/2020-07/themes.json`

 

I receive a CORS (‘Access-Control-Allow-Origin’ missing) error.

Can anyone help with this? Can the Admin API be accessed from the admin of an embedded app?

0 Likes
sircameron
Tourist
6 0 1

I've now attempted to use app bridge's authenticatedFetch, but the call is still failing due to CORS which kinda makes sense.
How is one supposed to make a call from a hosted embedded app running on a separate domain to a store's Admin Api running on the store's domain?

 

0 Likes
mthdvd
Tourist
8 0 0

sircameron --

Someone can correct me if I'm wrong, but I do not believe requests from the browser (client) to the Admin API is a good idea +/or possible. I'd recommend obtaining an access token and making such requests from the server of your embedded app.

This article outlines how: https://shopify.dev/tutorials/authenticate-with-oauth

Hope that helps!

0 Likes