提交 f4bc8391 authored 作者: 张立波's avatar 张立波

jst token

上级 0d1a279a
...@@ -56,8 +56,7 @@ func post(ctx context.Context, method string, req interface{}) (res string, err ...@@ -56,8 +56,7 @@ func post(ctx context.Context, method string, req interface{}) (res string, err
Start := gtime.TimestampMilli() Start := gtime.TimestampMilli()
Url := server.ApiUrl + method Url := server.ApiUrl + method
request := gjson.New(req) request := gjson.New(req)
err = request.Set("version", 2) err = request.Set("sign", sign(req))
err = request.Set("sign", sign(request.Map()))
if err != nil { if err != nil {
return return
} }
......
...@@ -51,6 +51,10 @@ func (s *tokenLogic) Init(ctx context.Context) (res *TokenInitRes, err error) { ...@@ -51,6 +51,10 @@ func (s *tokenLogic) Init(ctx context.Context) (res *TokenInitRes, err error) {
if err != nil { if err != nil {
return return
} }
if res.Code != 0 {
err = gerror.New("获取token失败")
return
}
conn := g.Redis().Ctx(ctx).Conn() conn := g.Redis().Ctx(ctx).Conn()
defer func() { defer func() {
_ = conn.Close() _ = conn.Close()
...@@ -69,7 +73,6 @@ type TokenRefreshReq struct { ...@@ -69,7 +73,6 @@ type TokenRefreshReq struct {
Timestamp string `json:"timestamp"` Timestamp string `json:"timestamp"`
GrantType string `json:"grant_type"` GrantType string `json:"grant_type"`
Charset string `json:"charset"` Charset string `json:"charset"`
Code string `json:"code"`
RefreshToken string `json:"refresh_token"` RefreshToken string `json:"refresh_token"`
Scope string `json:"scope"` Scope string `json:"scope"`
} }
...@@ -91,7 +94,6 @@ func (s *tokenLogic) Refresh(ctx context.Context, req string) (res *TokenRefresh ...@@ -91,7 +94,6 @@ func (s *tokenLogic) Refresh(ctx context.Context, req string) (res *TokenRefresh
Timestamp: gtime.TimestampStr(), Timestamp: gtime.TimestampStr(),
GrantType: "refresh_token", GrantType: "refresh_token",
Charset: "utf-8", Charset: "utf-8",
Code: grand.S(6),
RefreshToken: req, RefreshToken: req,
Scope: "all", Scope: "all",
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论