gnikyt / laravel-shopify

A full-featured Laravel package for aiding in Shopify App development
MIT License
1.24k stars 374 forks source link

"No authenticated user or shop domain" Ignore this for API routes #1188

Closed apurbajnu closed 2 years ago

apurbajnu commented 2 years ago

For bug reporting only! If you're posting a feature request or discussion, please ignore.

Expected Behavior

For custom API routes, I don't need verify.shopify middlewear

Current Behavior

During validation it give me this error "No authenticated user or shop domain"

Failure Information

Please help provide information about the failure if this is a bug.

Steps to Reproduce

Create routes in API. try to validate inputs. I have used auth:sanctum but not verify shopify middlewear.

Context

I want my merchant will be able to get and set data Via API of their visitors from our own database.

Failure Logs

[2022-08-14 09:02:36] local.ERROR: No authenticated user or shop domain {"exception":"[object] (Osiset\ShopifyApp\Exceptions\MissingShopDomainException(code: 0): No authenticated user or shop domain at /Users/apurbapodder/public_folder/ab/vendor/osiset/laravel-shopify/src/Traits/AuthController.php:33) [stacktrace]

0 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): Osiset\ShopifyApp\Http\Controllers\AuthController->authenticate(Object(Illuminate\Http\Request), Object(Osiset\ShopifyApp\Actions\AuthenticateShop))

1 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('authenticate', Array)

2 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Routing/Route.php(262): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Osiset\ShopifyApp\Http\Controllers\AuthController), 'authenticate')

3 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\Routing\Route->runController()

4 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Routing/Router.php(721): Illuminate\Routing\Route->run()

5 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

6 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

7 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))

8 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

9 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))

10 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

11 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))

12 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

13 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest(Object(Illuminate\Http\Request), Object(Illuminate\Session\Store), Object(Closure))

14 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))

15 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

16 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))

17 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

18 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))

19 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

20 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Routing/Router.php(723): Illuminate\Pipeline\Pipeline->then(Object(Closure))

21 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Routing/Router.php(698): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))

22 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))

23 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Routing/Router.php(651): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))

24 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))

25 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))

26 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

27 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))

28 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))

29 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

30 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))

31 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure))

32 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

33 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))

34 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

35 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))

36 /Users/apurbapodder/public_folder/ab/vendor/fruitcake/laravel-cors/src/HandleCors.php(38): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

37 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\Cors\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))

38 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

39 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Http\Middleware\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))

40 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

41 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\Pipeline\Pipeline->then(Object(Closure))

42 /Users/apurbapodder/public_folder/ab/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))

43 /Users/apurbapodder/public_folder/ab/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))

44 /Users/apurbapodder/.composer/vendor/laravel/valet/server.php(234): require('/Users/apurbapo...')

apurbajnu commented 2 years ago

@Kyon147 @osiset May you help me please to solve this issue,if possible.

Kyon147 commented 2 years ago

If you don't need the middleware on those routes you just need to omit the middleware on that route.

If you've omitted it and it's still happening it could be because the user class is overloaded.

I've used a separate API class and middleware using sanctum which might be why I didn't see this same error.

apurbajnu commented 2 years ago

@Kyon147 Thanks for replying. I have used different routes and different controllers. But still, the error is there if I try to validate all requests for that individual route. Only if I remove verify.shopify middleware from home routes, then the error is gone. I have tried, but how is this middleware connected with that route where one is in the web route, and the other is in the API route? Is it somehow related to ‘manual_routes’ in the config file?

apurbajnu commented 2 years ago

My bad. I was calling the 'HTTP/request' class. After that I have used request()->all(). Now everything is working fine. Thanks, @Kyon147.