diff --git a/idp/wechat.go b/idp/wechat.go index 43642c3a..cd1b1ef4 100644 --- a/idp/wechat.go +++ b/idp/wechat.go @@ -21,6 +21,7 @@ import ( "io" "net/http" "net/url" + "strings" "time" "golang.org/x/oauth2" @@ -98,6 +99,11 @@ func (idp *WeChatIdProvider) GetToken(code string) (*oauth2.Token, error) { return nil, err } + // {"errcode":40163,"errmsg":"code been used, rid: 6206378a-793424c0-2e4091cc"} + if strings.Contains(buf.String(), "errcode") { + return nil, fmt.Errorf(buf.String()) + } + var wechatAccessToken WechatAccessToken if err = json.Unmarshal(buf.Bytes(), &wechatAccessToken); err != nil { return nil, err