JWTAuth::attempt PHP Method

attempt() public static method

Attempt to authenticate the user and return the token.
public static attempt ( array $credentials = [], array $customClaims = [] ) : false | string
$credentials array
$customClaims array
return false | string
        public static function attempt($credentials = array(), $customClaims = array())
        {
            return \Tymon\JWTAuth\JWTAuth::attempt($credentials, $customClaims);
        }

Usage Example

 public function testRoute()
 {
     $customer = Customer::whereEmail('*****@*****.**')->first();
     $token1 = JWTAuth::attempt(["email" => '*****@*****.**', "password" => "admin"]);
     $token2 = JWTAuth::fromUser($customer);
     $access_token = $token1;
     $response = $this->call('GET', '/testtoken', [], [], array('HTTP_authorization' => 'bearer ' . $access_token, "HTTP_custom" => "custom header"));
     $this->assertTrue($response->isOk());
 }
All Usage Examples Of JWTAuth::attempt