From 2b7913311a6c679f6273939a592284e4629187f4 Mon Sep 17 00:00:00 2001 From: Malek Tellissi Date: Fri, 11 Sep 2026 03:12:20 +0200 Subject: [PATCH] Add temporary Shopify OAuth install routes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /shopify/install → redirects to Shopify OAuth /shopify/callback → exchanges code for access token and displays it To be removed after token is captured. Co-Authored-By: Claude Sonnet 4.6 --- .../Controllers/ShopifyInstallController.php | 54 +++++++++++++++++++ routes/web.php | 5 ++ 2 files changed, 59 insertions(+) create mode 100644 app/Http/Controllers/ShopifyInstallController.php diff --git a/app/Http/Controllers/ShopifyInstallController.php b/app/Http/Controllers/ShopifyInstallController.php new file mode 100644 index 0000000..6f207fa --- /dev/null +++ b/app/Http/Controllers/ShopifyInstallController.php @@ -0,0 +1,54 @@ +clientId = '1b6430c8cc94b5e58716235abd9bbd73'; + $this->clientSecret = config('services.shopify.webhook_secret'); + $this->shop = 'bluefootedboobyspices.myshopify.com'; + } + + public function install() + { + $url = "https://{$this->shop}/admin/oauth/authorize" + . "?client_id={$this->clientId}" + . "&scope={$this->scopes}" + . "&state=spicesetup"; + + return redirect($url); + } + + public function callback(Request $request) + { + $code = $request->query('code'); + + if (!$code) { + return response('Kein Code empfangen. ' . $request->getQueryString(), 400); + } + + $response = Http::post("https://{$this->shop}/admin/oauth/access_token", [ + 'client_id' => $this->clientId, + 'client_secret' => $this->clientSecret, + 'code' => $code, + ]); + + if ($response->failed()) { + return response('Token-Exchange fehlgeschlagen: ' . $response->body(), 500); + } + + $token = $response->json('access_token'); + + return response("
SHOPIFY_ACCESS_TOKEN={$token}
"); + } +} diff --git a/routes/web.php b/routes/web.php index 11fa2c8..a7114f5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,7 +1,12 @@