首页 > 其他分享 >开发密码登陆接口用postman测试报错“key is of invalid type”

开发密码登陆接口用postman测试报错“key is of invalid type”

时间:2023-06-08 11:22:04浏览次数:60  
标签:postman jwt invalid 报错 key SigningMethodES256 type

发现为go中jwt使用错误

我出错的地方为

// 出现错误地方为 tokenClaims := jwt.NewWithClaims(jwt.SigningMethodES256, claims) return tokenClaims.SignedString(jwtSecret) 我出错的点:加密方式选择了 jwt.SigningMethodES256 ,应该选择jwt.SigningMethodHS256 ,这个H是hash的意思,而SigningMethodES256是没有SignedString方法的 另一个常见错误: jwtSecret——这个key的底层是一个[]byte断言 --> key.([]byte),若此处传入的不是[]byte,将会报错key is invalid or of invalid type
参考链接:https://juejin.cn/post/7137156362651303966 作者:水纹
来源:稀土掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

标签:postman,jwt,invalid,报错,key,SigningMethodES256,type
From: https://www.cnblogs.com/PurpleGinsburg/p/17465661.html

相关文章