public function token(Request $request)
    {
        $authHeader = $request->header('Authorization');

        // Get for Auth Basic
        if (strtolower(substr($authHeader, 0, 5)) !== 'basic') {
            throw new UnauthorizedHttpException('Invalid authorization header, should be type basic');
        }

        // Get credentials
        $credentials = base64_decode(trim(substr($authHeader, 5)));

        list($login, $password) = explode(':', $credentials, 2);

        // Do auth
        if (! $token = auth()->attempt(['email' => $login, 'password' => $password])) {
            throw new UnauthorizedHttpException('Unauthorized login');
        }

        return $this->respondWithToken($token);
    }
public function token(Request $request)
    {
        $authHeader = $request->header('Authorization');

        // Get for Auth Basic
        if (strtolower(substr($authHeader, 0, 5)) !== 'basic') {
            throw new UnauthorizedHttpException('Invalid authorization header, should be type basic');
        }

        // Get credentials
        $credentials = base64_decode(trim(substr($authHeader, 5)));

        list($login, $password) = explode(':', $credentials, 2);

        // Do auth
        if (! $token = auth()->attempt(['email' => $login, 'password' => $password])) {
            throw new UnauthorizedHttpException('Unauthorized login');
        }

        return $this->respondWithToken($token);
    }
public function token ( Request $ request ) { $ authHeader = $ request -> header ( 'Authorization' ) ; // Get for Auth Basic if ( strtolower ( substr ( $ authHeader , 0 , 5 ) ) !== 'basic' ) { throw new UnauthorizedHttpException ( 'Invalid authorization header, should be type basic' ) ; } // Get credentials $ credentials = base64_decode ( trim ( substr ( $ authHeader , 5 ) ) ) ; list ( $ login , $ password ) = explode ( ':' , $ credentials , 2 ) ; // Do auth if ( ! $ token = auth ( ) -> attempt ( [ 'email' => $ login , 'password' => $ password ] ) ) { throw new UnauthorizedHttpException ( 'Unauthorized login' ) ; } return $ this -> respondWithToken ( $ token ) ; }
Get a JWT via given credentials.

@param Request $request
@return Response
Get a JWT via given credentials .