本文整理匯總了Golang中github.com/RangelReale/osin.AccessData.ExpireAt方法的典型用法代碼示例。如果您正苦於以下問題:Golang AccessData.ExpireAt方法的具體用法?Golang AccessData.ExpireAt怎麽用?Golang AccessData.ExpireAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/RangelReale/osin.AccessData
的用法示例。
在下文中一共展示了AccessData.ExpireAt方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GenerateAccessToken
func (c *AccessTokenGenJWT) GenerateAccessToken(data *osin.AccessData, generaterefresh bool) (accesstoken string, refreshtoken string, err error) {
// generate JWT access token
token := jwt.NewWithClaims(jwt.SigningMethodRS256, jwt.MapClaims{
"cid": data.Client.GetId(),
"exp": data.ExpireAt().Unix(),
})
accesstoken, err = token.SignedString(c.PrivateKey)
if err != nil {
return "", "", err
}
if !generaterefresh {
return
}
// generate JWT refresh token
token = jwt.NewWithClaims(jwt.SigningMethodRS256, jwt.MapClaims{
"cid": data.Client.GetId(),
})
refreshtoken, err = token.SignedString(c.PrivateKey)
if err != nil {
return "", "", err
}
return
}
示例2: GenerateAccessToken
func (c *AccessTokenGenJWT) GenerateAccessToken(data *osin.AccessData, generaterefresh bool) (accesstoken string, refreshtoken string, err error) {
// generate JWT access token
token := jwt.New(jwt.GetSigningMethod("RS256"))
token.Claims["cid"] = data.Client.GetId()
token.Claims["exp"] = data.ExpireAt().Unix()
accesstoken, err = token.SignedString(c.PrivateKey)
if err != nil {
return "", "", err
}
if generaterefresh {
// generate JWT access token
token = jwt.New(jwt.GetSigningMethod("RS256"))
token.Claims["cid"] = data.Client.GetId()
token.Claims["at"] = accesstoken
token.Claims["exp"] = data.ExpireAt().Unix()
refreshtoken, err = token.SignedString(c.PrivateKey)
if err != nil {
return "", "", err
}
}
return
}
示例3: GenerateAccessToken
func (j *JWT) GenerateAccessToken(data *osin.AccessData, generateRefresh bool) (accessToken string, refreshToken string, err error) {
claims, ok := data.UserData.(ClaimsCarrier)
if !ok {
return "", "", errors.Errorf("Could not assert claims to ClaimsCarrier: %v", claims)
}
claims["exp"] = data.ExpireAt()
if accessToken, err = j.SignToken(claims, map[string]interface{}{}); err != nil {
return "", "", err
} else if !generateRefresh {
return
}
if refreshToken, err = j.SignToken(claims, map[string]interface{}{}); err != nil {
return "", "", err
}
return
}