What to do next after installed shopify-api-php and merged shopify-app-template-php

kondonator
Shopify Partner
3 0 0

Hi.

I'm new on developing Shopify Custom App.

  1. I have created the custom app as explained in this page .
  2. I have installed Laravel on the server as explained in this page.
  3. I have installed this library and merged this template.
  4. I have created the test shop and could installed the custom app from the shop admin panel into the shop successfully.
  5. Next I want to authenticate the shop and there is a route to authenticate the shop in the template as follows:
    Route::get('/api/auth', function (Request $request) {
        $shop = Utils::sanitizeShopDomain($request->query('shop'));
    
        // Delete any previously created OAuth sessions that were not completed (don't have an access token)
        Session::where('shop', $shop)->where('access_token', null)->delete();
    
        return AuthRedirection::redirect($request);
    });
    
    Route::get('/api/auth/callback', function (Request $request) {
        $session = OAuth::callback(
            $request->cookie(),
            $request->query(),
            ['App\Lib\CookieHandler', 'saveShopifyCookie'],
        );
    
        $host = $request->query('host');
        $shop = Utils::sanitizeShopDomain($request->query('shop'));
    
        $response = Registry::register('/api/webhooks', Topics::APP_UNINSTALLED, $shop, $session->getAccessToken());
        if ($response->isSuccess()) {
            Log::debug("Registered APP_UNINSTALLED webhook for shop $shop");
        } else {
            Log::error(
                "Failed to register APP_UNINSTALLED webhook for shop $shop with response body: " .
                print_r($response->getBody(), true)
            );
        }
    
        $redirectUrl = Utils::getEmbeddedAppUrl($host);
        if (Config::get('shopify.billing.required')) {
            list($hasPayment, $confirmationUrl) = EnsureBilling::check($session, Config::get('shopify.billing'));
    
            if (!$hasPayment) {
                $redirectUrl = $confirmationUrl;
            }
        }
    
        return redirect($redirectUrl);
    });
    But I have no idea how to call this route.

Can anyone let me know how to authenticate or show me the explanation or sample?

Thanks in advance.

 

Reply 1 (1)

kondonator
Shopify Partner
3 0 0

I could solve this issue by myself.

I updated the application URL with /api/auth from the dashboard and installed the application then this url was called and authenticated.