I am writing a react frontend which lets users login with their shopify credentials. I used the client id given in my app credentials section, however when i click to login i get the error shown in the image. Code:
import React, { useState } from "react";
const ShopifyLogin = () => {
const [loggedIn, setLoggedIn] = useState(false);
const handleLogin = () => {
const clientId = "MY_SHOPIFY_API_KEY";
const redirectUri = "MY_REDIRECT_URI";
const scope = "read_products";
const loginUrl = `https://accounts.shopify.com/auth?client_id=${clientId}&scope=${scope}&redirect_uri=${redirectUri}&response_type=code`;
window.location.href = loginUrl;
};
const checkAuthorizationCode = () => {
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get("code");
if (code) {
setLoggedIn(true);
window.location.href = "/dashboard";
}
};
React.useEffect(() => {
checkAuthorizationCode();
}, []);
return (
{!loggedIn ? (
) : (
You are logged in with Shopify.
)}
);
};
export default ShopifyLogin;
The error:
