The redirect_uri is not whitelisted

I am creating app but, the here I am getting strange error The redirect_uri is not whitelisted but, I already defined the url properly:

https://www.purchasetheme.com/justboughtit/generate_token.php

In the code as well it is define properly:
// Redirect URI must be whitelisted in Shopify app settings
$redirect_uri = “https://www.purchasetheme.com/justboughtit/generate_token.php”;

// Generate secure random state
$state = bin2hex(random_bytes(16));
$_SESSION[‘oauth_state’] = $state;

// Save incoming host param for later
if (!empty($_GET[‘host’])) {
$_SESSION[‘host’] = $_GET[‘host’];
}

session_write_close();

// — Build OAuth URL —
$install_url = “https://$shop/admin/oauth/authorize?” .
“client_id=” . urlencode($api_key) .
“&scope=” . urlencode($scopes) .
“&redirect_uri=” . urlencode($redirect_uri) .
“&state=” . urlencode($state);

// Include host param if present (for embedded apps)
if (!empty($_GET[‘host’])) {
$install_url .= “&host=” . urlencode($_GET[‘host’]);
}

// Redirect user to Shopify install screen
header(“Location: $install_url”);
exit;

but, in the shopify redirect it shows error:
https://admin.shopify.com/store/memedownload/oauth/authorize?client_id=f695b1811cb0c61d054d4a3e70f1035c&scope=read_products%2Cwrite_products%2Cread_customers%2Cwrite_customers%2Cread_orders%2Cwrite_orders%2Cread_fulfillments%2Cwrite_fulfillments%2Cread_draft_orders%2Cwrite_draft_orders%2Cwrite_publications%2Cread_publications&redirect_uri=https%3A%2F%2Fwww.purchasetheme.com%2Fjustboughtit%2Fgenerate_token.php&state=bec155b1f2f376c5709bdc606388b970&host=YWRtaW4uc2hvcGlmeS5jb20vc3RvcmUvbWVtZWRvd25sb2Fk

please please help to fix it.

Have you configured this redirect url in your shopify toml file or partner dashboard?
Have you turned off managed installs as it looks like you are doing install manually? Or have you considered using managed installs?

1 Like

Are you still seeing this issue @Richard_Mayer or ca I mark this as solved?

Yes, you can mark it as closed.