Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

miquelangeld's avatar

Passport API returns an array with credentials instead only json

Hi! i'm testing Passport and i have this function:

public function login(Request $request){

    if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){

        $user = Auth::user();
        $success['token'] =  $user->createToken('MyApp')->accessToken;
        return response()->json(['success' => $success], $this->successStatus);

    }

    else{

        return response()->json(['error'=>'Unauthorised'], 401);

    }

}

When I test Passport all works fine, i send user and password and this function return the access Token, but I realize that in the raw response i always get an array with the post data:

Array ( [email] => [email protected] [password] => 123456 ) {"success":{"token":"Z6sl_xbeY9ve492HSwEICcu1im6TiJds"}}

I'm building an app with App inventor and I get an error trying to decode the json because this array with the post data.

0 likes
0 replies

Please or to participate in this conversation.