gnikyt / laravel-shopify

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

routes/api.php Cannot get shopify name #799

Closed zhiyicai closed 3 years ago

zhiyicai commented 3 years ago

ErrorException Trying to get property 'name' of non-object

routes/api.php Cannot get shopify name!

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;

Route::get('/influencers', function () {
    $shop = Auth::user();
    dd($shop->name);
});

version laravel: 8 "osiset/laravel-shopify": "^16.0",

shopify name can be retrieved normally on routes/web.php

Can someone help me Thank you very much

mrwhale commented 3 years ago

I believe you still need to use the Shopify Middleware for API routes if you want it to auth against a shop

I've used auth.shopify before but it looks like auth.token may be more suitable here (if you are using a bearer token for API requests to your app)

https://github.com/osiset/laravel-shopify/tree/master/src/ShopifyApp/Http/Middleware