How to visit the API page of Shopify embed app without login required?

135 views Asked by At

I make a React Remix-based Shopify embed app, and wrote an API, the file is called api.access.js in the routes folder.

export async function loader({ request }) {
    const { session } = await authenticate.admin(request);
    const { shop } = session;
    const url = new URL(request.url);
    const code = url.searchParams.get("code");

    if(code && code !== 'undefined') {
        // The next things to do....
    }else{
        return null;
    }
}

Now, when I got the code=MY-CODE from the third-party API and redirect to this page as https://xxxxx.com/api/access?code=MY-CODE, the page will be redirect to the shopify shop login page, so that I can't get the URL param, the codes above was stopped at const { session } = await authenticate.admin(request), then redirected.

Anyone could give me a correct direction that can inspire me to fix this issue.

Thanks!!!

I hope when the third-party app redirects the URL to https://xxxxx.com/api/access?code=MY-CODE, I can get the code=MY-CODE as well as the shop session in the API page.

0

There are 0 answers