title: Laravel Passport - Not able to get token string in response?
body: <p>i am getting result like below in registration using passport laravel</p>
  <pre><code>&quot;success&quot;: {
          &quot;token&quot;: {
              &quot;name&quot;: &quot;MyApp&quot;,
              &quot;abilities&quot;: [
                  &quot;*&quot;
              ],
              &quot;tokenable_id&quot;: 6,
              &quot;tokenable_type&quot;: &quot;App\\Models\\User&quot;,
              &quot;updated_at&quot;: &quot;2021-08-28T14:41:33.000000Z&quot;,
              &quot;created_at&quot;: &quot;2021-08-28T14:41:33.000000Z&quot;,
              &quot;id&quot;: 5
          },
          &quot;name&quot;: &quot;Test&quot;
  </code></pre>
  <p>I want to get the token string in response ...what to do now.</p>
  <h1>Below my api controller function :</h1>
  <pre><code>namespace App\Http\Controllers\Auth;
  
  use App\Http\Controllers\Controller;
  use Illuminate\Http\Request;
  use App\Models\User;
  class ApiController extends Controller
  {
      public function register(Request $request) 
      { 
          $successStatus = 200;
          $validator = \Validator::make($request-&gt;all(), [ 
              'name' =&gt; 'required', 
              'email' =&gt; 'required|email', 
              'password' =&gt; 'required', 
          ]);
          if ($validator-&gt;fails()) { 
                      return response()-&gt;json(['error'=&gt;$validator-&gt;errors()], 401);            
                  }
          $input = $request-&gt;all(); 
          $input['password'] = \Hash::make($input['password']); 
          $user = User::create($input); 
          $success['token'] =  $user-&gt;createToken('MyApp')-&gt;accessToken; 
          $success['name'] =  $user-&gt;name;
          return response()-&gt;json(['success'=&gt;$success],200); 
      }
  }
  </code></pre>