Laravel Passport Invalid credentials grant_type - Password

I am having difficulty setting up Passport in Laravel 5.6. The first time when I followed this tutorial, I had implemented perfectly but now again when I am following than getting following error.

    "error": "invalid_credentials",
    "message": "The user credentials were incorrect."

I have tried out all possible solutions but none of them works. So thought to post it here.

Info: I am using iMac - High Sierra. storage directory has 777 permission. I have set using sudo chmod -R 777 storage command. However, when I checked the laravel.log file didn't have permission so I have grant 777 to it as well. still getting the error.

Laravel error log - laravel.log

local.ERROR: The user credentials were incorrect. {"exception":"[object] (League\\OAuth2\\Server\\Exception\\OAuthServerException(code: 6): The user credentials were incorrect. at /Users/username/Sites/mysite/vendor/league/oauth2-server/src/Exception/OAuthServerException.php:160)

My Implementation Steps

  • I run composer require laravel/passport
  • Added passport service provider in app.php Laravel\Passport\PassportServiceProvider::class,
  • Migrated the database php artisan migrate
  • Added Passport::routes()
  • Added use HasApiTokens to User model
  • In auth.php set gourds api driver to password
  • Passport client credentials php artisan passport:client --passoword
  • Passport keys php artisan passport:keys
  • Added route and register controller as below


Route::post( 'register', 'Api\Auth\[email protected]' );

RegisterController Class

namespace App\Http\Controllers\Api\Auth;

use App\User;
use function bcrypt;
use function dd;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Route;
use Laravel\Passport\Client;
use function response;

class RegisterController extends Controller

	private $client;

	public function __construct() {
		$this->client = Client::findOrFail(1);

	public function register( Request $request ) {

		$this->validate( $request, [
			'name'     => 'required',
			'email'    => 'required|email|unique:users,email',
			'password' => 'required|min:6|confirmed',
		] );

		$user = User::create( [
			                      'name'     => request( 'name' ),
			                      'email'    => request( 'email' ),
			                      'password' => bcrypt( 'password' )
		                      ] );

		$params = [
			'grant_type'    => 'password',
			'client_id'     => $this->client->id,
			'client_secret' => $this->client->secret,
			'username'      => request( 'email' ),
			'password'      => request( 'password' ),
			'scope'         => '*'

		$request->request->add( $params );
		$proxy = Request::create( 'oauth/token', 'POST' );

		return Route::dispatch( $proxy );

Code Lover replied 11 months ago


Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us