I'm not getting correct access token in laravel

hey i’m trying to creating an custom app using laravel but here when i try to get the access token im always getting the online access token

public function redirecturl(Request $request){

$apikey = "api key";

$apisecret = “api secret”;

$redirect_url=“using ngrok redirect url”;

$shop = $request->get(‘shop’); // shop domain

$code = $request->get(‘code’); // Shopify code

// 1. Exchange code for access token

$getaccestoken = Http::post(“https://{$shop}/admin/oauth/access_token”, [

‘client_id’ => $apikey,

‘client_secret’ => $apisecret,

‘code’ => $code,

\]);

// dd($getaccestoken);

$data = $getaccestoken->json();

dd($data);

$access_token = $data[‘access_token’];

if (!$accessToken) {

return response(‘Access token not received’, 500);

    }

// 2. Save in database

Shopsdata::updateOrInsert(

    \['shop_name' => $shop\],

    \['access_token' => $access_token\]

);

return “App installed successfully!”;

}

The type of access token you receive (online or offline) is determined during the initial authorization request, when you redirect the user to Shopify to grant permissions, not during the access_token exchange itself.

If you’re consistently getting an online access token, it means your initial authorization URL isn’t configured to request an offline token. To get an offline access token, you need to include &grant_options[]=per-user (or just &grant_options[] for a non-per-user offline token, though per-user is generally preferred for custom apps) in the query string of the authorization URL you construct before redirecting the merchant to https://{shop}/admin/oauth/authorize.

Your current token exchange code will correctly process whatever type of token Shopify issues based on that initial request. Make sure the grant_options parameter is present when you build the redirect URL to /admin/oauth/authorize.

Hope that helps!