"error": "invalid_grant" Laravel 7 Passport

Viewed 861

I used Laravel 7 with passport but get some error

This is my Controller

class LoginController extends Controller
{
    public function login(Request $request)
    {
        $response = Http::post(
            'http://localhost/vue-spa/public/oauth/token',
            [
                'grant_type'    => 'password',
                'client_id'     => 2,
                'client_secret' => 'Z7YFRiUQITRGkWAgCuI8rNyss7BVQJDQXMZrRWiR',
                'username'      => $request->email,
                'password'      => $request->password,
                'scope'         => '',
            ]
        );

        if ($response->clientError()) {
            return $response->json('Email atau Password Salah', 400);
        } elseif ($response->serverError()) {
            return $response->json('Server Error', 500);
        }

        return $response->body();
    }
}

And I get Error Like this

enter image description here

I have to solve this problem

Just replace

'grant_type' => 'password'

to

'grant_type' => 'client_credentials'
1 Answers

I have to solve this problem

Just replace

'grant_type' => 'password'

to

'grant_type' => 'client_credentials'
Related