Shopify app-bridge redirect outside admin iframe

Hi, I’m trying to develop a shopify admin app to export merchant’s orders in a format compatible with our application, so I need to call admin api.
I’m trying to install the app using shopify/app-bridge as explained here https://help.shopify.com/en/api/embedded-apps/app-bridge/oauth, but every time, after installation, shopify redirect on my website outside the iframe.

This is my code;

https://xxx.ngrok.io/shopify:

const redirectUri = "https://xxxx.ngrok.io/shopify-auth";   
var urlParams = new URLSearchParams(window.location.search);
var shopOrigin = urlParams.get('shop');
const permissionUrl = `/oauth/authorize?client_id=${apiKey}&scope=read_products,read_content&redirect_uri=${redirectUri}`;

if (window.top == window.self) {
     window.location.assign(`https://${shopOrigin}/admin${permissionUrl}`)
} else {
    const app = createApp({
       apiKey: apiKey,
       shopOrigin: shopOrigin,
       forceRedirect: true
   });
   console.log('bridge redirect')
   Redirect.create(app).dispatch(Redirect.Action.ADMIN_PATH, permissionUrl);
}

https://xxx.ngrok.io/shopify-auth****:

var urlParams = new URLSearchParams(window.location.search);
var code = urlParams.get('code');
var shop = urlParams.get('shop');

Here I can get the code and I can call my server that call the

https://shopname.myshopify.com/admin/oauth/access_token

to get the access_token and call the admin api, but at this point I’m out of shopify iframe.

Can anyone help me?

I can be more clear if needed.

Thanks,

regards

Davide

Hello!

Did you manage to fix this?

I have the exact same problem…

Hi,

no I didn’t and we decided to suspend the project at the moment.

Not sure if this helps, but we ended up returning a redirect to (at the end of the auth process):

https:///admin/apps//

Where path is a relative path on your application domain.

Not sure where I found this, but I searched for a long time.

Cheers, that worked!

note that for me, = my app’s name when I first set up the app. I’m not even sure how to change it haha. I have this app name that is similar to “test-app1” and that’s the path that shopify wants. My app id is numbers like “2938429384” and putting that in the path doesn’t work.

@fnbuild My app was fine in local and live but recent I can see the some customer side I am still getting the issue.

**admin.shopify.com** redirected you too many times.
why this happens ?

any suggestion for this issue ?