-3

I can'understand how can I do so Please help me to find a solution

$response = $client->request('POST', '/api/profile_update', [
   
     'headers' => [
         'Authorization' => 'Bearer '.$token,
         'Accept' => 'application/json',
      ],
]);
return $response;

I used something like this in api.php file

now what can i do in controller file.

Rakesh kumar Oad
  • 1,332
  • 1
  • 15
  • 24

2 Answers2

0
                  $tokenResult = $user->createToken('Personal token');
                    
                    $token = $tokenResult->token;
                    $token->save();
                    return response()->json([
                        'success'   => true,
                        'access_token' => $tokenResult->accessToken,
                        'token_type' => 'Bearer',
                        'expires_at' => Carbon::parse(
                            $tokenResult->token->expires_at
                        )->toDateTimeString()
                  ]);
-2

you save user token in database-in user table and check it with given token from request

if they are same you get user information