我用的是:"tymon/jwt-auth": "1.0.0-rc.1"

根据官方网站http://jwt-auth.readthedocs.io安装,并且vender:publish完配置文件后,需要按照官网的Update your User model章节配置一下auth所需要的一些类。我第一次用jwt-auth,没有进行按照Update your User model章节进行操作,并且所用的Eloquent也和官网不太一样,遇到了3个问题,在此总结一下:

1、config/auth.php

'guards' => [
'api' => [
'driver' => 'jwt',
'provider' => 'myexample',
],
],

结果在此文件下面的 'providers' 数组中忘记写 'myexample' 相关的 'driver' 和 'model' 了,导致了错误1:

 "message": "Type error: Argument 2 passed to Tymon\\JWTAuth\\JWTGuard::__construct() must be an instance of Illuminate\\Contracts\\Auth\\UserProvider, null given, called in ...

问题2和3都是Eloquent Model中遇到的问题,没按照官网Update your User model章节所述导致的,解决办法就是像官网说的改改Auth用到的Model即可,主要是需要Model实现两个接口

2、Model没有实现JWTSubject接口报错:

 "message": "Type error: Argument 1 passed to Tymon\\JWTAuth\\JWTGuard::login() must be an instance of Tymon\\JWTAuth\\Contracts\\JWTSubject, instance of App\\Entities\\Authors given, called in ...

3、Model没有实现AuthenticatableContract接口(契约)报错:

"message": "Type error: Argument 1 passed to Tymon\\JWTAuth\\JWTGuard::setUser() must be an instance of Illuminate\\Contracts\\Auth\\Authenticatable, instance of App\\Entities\\Authors given, called in ...


jwt-auth错误小结的更多相关文章

  1. 【翻译】REST framework JWT Auth(django rest framework-jwt)

    JWT认证的REST框架 原文链接 概述 这个包提供对Django REST framework的JSON Web Token 认证支持. 需要满足条件 Python (2.7, 3.3, 3.4, ...

  2. <转>Python运行的17个时新手常见错误小结

    1)忘记在 if , elif , else , for , while , class ,def 声明末尾添加 :(导致 “SyntaxError :invalid syntax”) 该错误将发生在 ...

  3. libc++abi.dylib: terminate_handler unexpectedly threw an exception错误小结

    说法一: 我们在运行xcode工程时,有时候会遇到”libc++abi.dylib: terminate_handler unexpectedly threw an exception”错误,app莫 ...

  4. 微信支付errcode:40163,code been used,错误小结

    1.配置时注意,支付平台中的支付授权目录, 注意大小写. 昨天碰到的问题,就是自己跳转时,路径写的全小写.跳转支付页面也能跳转过去,但是log中总是调用两次code,报40163错误.后改成和公总号支 ...

  5. Nodejs运行错误小结

    (迁移自旧博客2017 04 15) 在使用过程中会遇到一些问题,学习过程中不定期更新. 问题一 错误如下 **events.js:72 throw er; // Unhandled 'error' ...

  6. GCC编译错误小结

    gcc编译时对’xxxx’未定义的引用问题可能错误 错误一: 没有实现xxxx 错误二: c++引用c语言so库,但是so库头文件没有extern "C" 错误三: 检查各个共享库 ...

  7. (转)Springboot+shiro配置笔记+错误小结

    springboot不像springmvc,它没有xml配置文件,那该如何配置shiro呢,其实也不难,用java代码+注解来解决这个问题.仅以此篇记录我对shiro的学习,如有对过客造成不便,实在抱 ...

  8. Springboot+shiro配置笔记+错误小结

    软件152 尹以操 springboot不像springmvc,它没有xml配置文件,那该如何配置shiro呢,其实也不难,用java代码+注解来解决这个问题.仅以此篇记录我对shiro的学习,如有对 ...

  9. Python运行的17个时新手常见错误小结

    1)忘记在if , elif , else , for , while , class ,def 声明末尾添加 :(导致“SyntaxError :invalid syntax”) 该错误将发生在类似 ...

随机推荐

  1. centos7 搭建DHCP服务器

    一.DHCP简单讲解 DHCP就是动态主机配置协议(Dynamic Host Configuration Protocol)是一种基于UDP协议且仅限用于局域网的网络协议,它的目的就是为了减轻TCP/ ...

  2. 计划任务at、crontab

    at一次性计划任务 格式: at + 时间 命令 安装at # yum install at -y 如果执行at命令时,出现一下情况 Can't open /var/run/atd.pid to si ...

  3. [UE4]背景模糊

    被遮挡的都会被模糊,没被遮挡的不会模糊

  4. http、TCP/IP协议与socket之间的区别(转载)

    http.TCP/IP协议与socket之间的区别  https://www.cnblogs.com/iOS-mt/p/4264675.html http.TCP/IP协议与socket之间的区别   ...

  5. android 将项目下的数据库拷贝到sd卡中

    /** * 将项目下的数据库拷贝到sd卡中 */ public static boolean copyDbToSdCard() { FileInputStream fis = null; FileOu ...

  6. spring 配置文件的头部 xmls

    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w ...

  7. Socket网络编程(winform)

    [服务器] using System; using System.Collections.Generic; using System.ComponentModel; using System.Data ...

  8. xinetd网络(2) 协议头解析

    1:在/etc/xinetd.d下添加配置文件xhttpd service xhttpd { socket_type = stream //每行“=”前后各最多只能有一个空格 protocol= tc ...

  9. es6 import export 引入导出变量方式

    var testdata='sdfkshdf'; //export testdata;//err export {testdata as ms}; export var firstName = 'Mi ...

  10. MYSQL存储过程中 使用变量 做表名

    ); DECLARE temp2 int; set temp1=m_tableName; set temp2=m_maxCount; set @sqlStr=CONCAT('select * from ...