Correct workflow for developing a custom app to be transferred to a client store when done

Excursionist
20 0 2

Hi all,

 

New to Shopify APP development. I am creating an app for a development store in my partner account dashboard.

 

I have created a custom app and have used https://github.com/nyalex/shopify-generating-api-token-guide as the basis of my app which I have uploaded to our server.

 

I setup my custom app, add the files to the server, generate api credentials, etc. Then I go to a URL like the one below:

 

https://my-dev-store.myshopify.com/admin/oauth/request_grant?client_id=123456789&redirect_uri=https%...

 

On this page I get a message saying "This app can't be installed using this link. Contact the app developer for more information." And the 'install app' button is greyed out.

 

As an alternative I went into the app directly in my partner dashboard, clicked on the 'test on development store' link, choose my store only to get the notification "Installing this app on this development store will permanently disable transfer, which means store ownership can’t be transferred to a client."

 

As a further alternative I went into the app, generated the link to get something like: https://my-dev-store.myshopify.com/admin/oauth/install_custom_app?client_id=12345678&signature=abcey...

 

Which when clicked simple loads the index.php file on my server at the location of my app.

 

I want to develop this custom app for a development store that I will transfer to the client once it is ready to be published in a few months so I am curious as to the correct workflow here.

 

 

 

 

0 Likes
Highlighted
Excursionist
20 0 2

Just to follow up on this, this thread seems to indicate that an unpublished public app is what I want: https://community.shopify.com/c/Shopify-APIs-SDKs/Working-solution-that-replaces-private-apps-url-pr...

 

However is this still relevant as I think that post is from before custom apps became part of Shopify?

 

All I want to do is build a simply app, hosted on my server that uses PHP to talk to the products API so I can dynamically build and price products on the fly. I just can't get this handshake to work that installs the app.

0 Likes
Highlighted
New Member
6 0 0

Bump. I have this *identical* issue, same git, same result — I've also been through the shopify plus chat help with no luck — directed me here. I've repeated by creating several new apps to run through and double check the process — cannot get any of them to authenticate and install. 'generate_token.php' didn't return a token.

 

Anyone have any ideas? Seems like it should be simple. Very frustrating.

0 Likes
Highlighted
New Member
6 0 0

 

Just to follow up on this, this thread seems to indicate that an unpublished public app is what I want: https://community.shopify.com/c/Shopify-APIs-SDKs/Working-solution-that-replaces-private-apps-url-pr...

 



FWIW, plus support told me that a custom app *is* the way to go.

0 Likes
Highlighted
Excursionist
20 0 2

Hi @Cleay 

 

Thanks. Yeah I got it working. I had to generate the link that connects the app to the store. The actual generated app installation URL does not work but it allows me then to install the app using the "store-name.myshopify.com/admin/oauth/authorize?client_id=... link.

 

Took a bi of trial and error to work this out but I can install a custom app as and when needed.

 

0 Likes
Highlighted
New Member
6 0 0

install.php:

<?php

// Set variables for our request
$shop = $_GET['shop'];
$api_key = "XXXXXXXXXXXXXXXXXXXXXX";
$scopes = "read_orders,write_products";
$redirect_uri = "https://myurl.com/shopify_apps/generate_token.php";

// Build install/approval URL to redirect to
$install_url = "https://" . $shop . ".myshopify.com/admin/oauth/authorize?client_id=" . $api_key . "&scope=" . $scopes . "&redirect_uri=" . urlencode($redirect_uri);

// Redirect
header("Location: " . $install_url);
die();

generate_token.php:

<?php

// Get our helper functions
require_once("inc/functions.php");

// Set variables for our request
$api_key = "XXXXXXXXXXXXXXX";
$shared_secret = "XXXXXXXXXXXXXXXX";
$params = $_GET; // Retrieve all request parameters
$hmac = $_GET['hmac']; // Retrieve HMAC request parameter

$params = array_diff_key($params, array('hmac' => '')); // Remove hmac from params
ksort($params); // Sort params lexographically

$computed_hmac = hash_hmac('sha256', http_build_query($params), $shared_secret);

// Use hmac data to check that the response is from Shopify or not
if (hash_equals($hmac, $computed_hmac)) {

	// Set variables for our request
	$query = array(
		"client_id" => $api_key, // Your API key
		"client_secret" => $shared_secret, // Your app credentials (secret key)
		"code" => $params['code'] // Grab the access key from the URL
	);

	// Generate access token URL
	$access_token_url = "https://" . $params['shop'] . "/admin/oauth/access_token";

	// Configure curl client and execute request
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_URL, $access_token_url);
	curl_setopt($ch, CURLOPT_POST, count($query));
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($query));
	$result = curl_exec($ch);
	curl_close($ch);

	// Store the access token
	$result = json_decode($result, true);
	$access_token = $result['access_token'];

	// Show the access token (don't do this in production!)
	echo $access_token;

} else {
	// Someone is trying to be shady!
	die('This request is NOT from Shopify!');
}

Run install.php:
https://myurl.com/shopify_apps/install.php?page=myshopname

0 Likes
Highlighted
Excursionist
20 0 2

@Cleay that is exactly the same script I am using but after going to the install screen for the app (where the app is authorised) a message appeared saying that the app couldn't be installed via that method.

 

The only way I could fix this was to generate the merchant install link even though I don't use it and then use https://myurl.com/shopify_apps/install.php?page=myshopname

0 Likes
Highlighted
New Member
6 0 0

Oh nice! Can you elaborate on that working install link? — how does it differ from the generated one?

0 Likes
Highlighted
New Member
6 0 0

@garethrane  Got it! — lots of trial and error like you said, but got there. Your help is much appreciated.

0 Likes
Highlighted
Excursionist
20 0 2

@Cleay did you get it to work by generating the merchant install link even though you don't actually need to use it?

0 Likes