invalid operation: token.Claims["ID"] (type jwt.Claims does not support indexing) #143

Projects

None yet

6 participants

@LeBronoMars @kwk @dgrijalva @Hokutosei @mikepc @girgen
@LeBronoMars
LeBronoMars commented  on 18 Jun •  edited

This is working fine in my localhost, but when i'm trying it in aws ec2..i cant build and i'm getting the ff. error
screen shot 2016-06-18 at 10 26 39 am

and here is my code
screen shot 2016-06-18 at 10 21 46 am

@LeBronoMars
LeBronoMars commented  on 18 Jun

Ohh ok..sorry.. there's an update..gonna close this one

@LeBronoMars  LeBronoMars closed this  on 18 Jun
@kwk
kwk commented  on 21 Jun

I have the same issue and I'd like to know which update you were talking about @LeBronoMars

@dgrijalva
Owner
dgrijalva commented  on 22 Jun

@kwk this library was updated at the end of last week. The API for Claims has changed. Seehttps://github.com/dgrijalva/jwt-go/blob/master/MIGRATION_GUIDE.md for details. Or you can continue to use 2.x.

@Hokutosei
Hokutosei commented  on 14 Jul •  edited

@dgrijalva I'm having the same problem, I wonder how did everyone solved this problem? it really did devastated our auths, and I am seeing a little to no time for fixing these changes. the migration_guide has little information to no example of code changes rather than going to docs. I'd rather stay to 2.x than updating to 3.x

here is some of my code.

    token := jwt.New(jwt.SigningMethodRS512)
    token.Claims["exp"] = time.Now().Add(time.Hour * time.Duration(settings.Get().JWTExpirationDelta)).Unix()
    token.Claims["iat"] = time.Now().Unix()
@dgrijalva
Owner
dgrijalva commented  on 15 Jul

@Hokutosei you can stay with the 2.x line and things will keep working fine for you.

To update that sample code to 3.x, do the following:

    token := jwt.New(jwt.SigningMethodRS512)
    claims := make(jwt.MapClaims)
    claims["exp"] = time.Now().Add(time.Hour * time.Duration(settings.Get().JWTExpirationDelta)).Unix()
    claims["iat"] = time.Now().Unix()
    token.Claims = claims
@dgrijalva
Owner
dgrijalva commented  on 15 Jul

OR

    token := jwt.New(jwt.SigningMethodRS512)
    token.Claims = jwt.MapClaims{
        "exp": time.Now().Add(time.Hour * time.Duration(settings.Get().JWTExpirationDelta)).Unix(),
        "iat": time.Now().Unix(),
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值