Skip to content

Commit

Permalink
OAuth2用户授权修改,增加ResultOAuthUserDetail
Browse files Browse the repository at this point in the history
  • Loading branch information
liniu committed Dec 20, 2023
1 parent 5a1a2dd commit 6bdcf67
Show file tree
Hide file tree
Showing 211 changed files with 460 additions and 431 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

[![golang](https://img.shields.io/badge/Language-Go-green.svg?style=flat)](https://golang.org) [![GitHub release](https://img.shields.io/github/release/shenghui0779/gochat.svg)](https://github.com/shenghui0779/gochat/releases/latest) [![pkg.go.dev](https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/shenghui0779/gochat) [![Apache 2.0 license](http://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](http://opensource.org/licenses/apache2.0)


## 👉 该项目不再更新,请使用 [新SDK](https://github.com/shenghui0779/wechat)

## 说明:原项目已经停更,我有项目依赖,我是初学者,只好硬着头皮更新


📦 微信 Go SDK

| 模块 | 功能 |
Expand Down
4 changes: 2 additions & 2 deletions corp/addrbook/department.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"strconv"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type ParamsDepartmentCreate struct {
Expand Down
4 changes: 2 additions & 2 deletions corp/addrbook/department_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
)

func TestCreateDepartment(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions corp/addrbook/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package addrbook
import (
"encoding/json"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type ParamsExport struct {
Expand Down
4 changes: 2 additions & 2 deletions corp/addrbook/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
)

func TestExportSimpleUser(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions corp/addrbook/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package addrbook
import (
"encoding/json"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type BatchType string
Expand Down
4 changes: 2 additions & 2 deletions corp/addrbook/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
)

func TestBatchSyncUser(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions corp/addrbook/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"strconv"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type ParamsTagCreate struct {
Expand Down
4 changes: 2 additions & 2 deletions corp/addrbook/tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
)

func TestCreateTag(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions corp/addrbook/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"strconv"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type ExternalProfile struct {
Expand Down
4 changes: 2 additions & 2 deletions corp/addrbook/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
)

func TestCreateUser(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions corp/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"strconv"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type ResultAgentGet struct {
Expand Down
4 changes: 2 additions & 2 deletions corp/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
"github.com/stretchr/testify/assert"
)

Expand Down
4 changes: 2 additions & 2 deletions corp/agent/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"strconv"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

// ButtonType 菜单按钮类型
Expand Down
4 changes: 2 additions & 2 deletions corp/agent/menu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
"github.com/stretchr/testify/assert"
)

Expand Down
4 changes: 2 additions & 2 deletions corp/agent/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package agent
import (
"encoding/json"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type TplType string
Expand Down
4 changes: 2 additions & 2 deletions corp/agent/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
"github.com/stretchr/testify/assert"
)

Expand Down
10 changes: 5 additions & 5 deletions corp/corp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

"github.com/tidwall/gjson"

"github.com/shenghui0779/gochat/event"
"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/event"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type Corp struct {
Expand All @@ -27,8 +27,8 @@ func (corp *Corp) CorpID() string {

// OAuth2URL 生成网页授权URL(请使用 URLEncode 对 redirectURL 进行处理)
// [参考](https://open.work.weixin.qq.com/api/doc/90000/90135/91020)
func (corp *Corp) OAuth2URL(scope AuthScope, redirectURL, state string) string {
return fmt.Sprintf("%s?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s#wechat_redirect", urls.Oauth2Authorize, corp.corpid, redirectURL, scope, state)
func (corp *Corp) OAuth2URL(scope AuthScope, redirectURL, state, agentID string) string {
return fmt.Sprintf("%s?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s&agentid=%s#wechat_redirect", urls.Oauth2Authorize, corp.corpid, redirectURL, scope, state, agentID)
}

// QRCodeAuthURL 生成扫码授权URL(请使用 URLEncode 对 redirectURL 进行处理)
Expand Down
6 changes: 3 additions & 3 deletions corp/corp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/mock"
"github.com/stretchr/testify/assert"
)

func TestOAuth2URL(t *testing.T) {
cp := New("CORPID")

authURL := cp.OAuth2URL(ScopeSnsapiBase, "REDIRECT_URI", "STATE")
authURL := cp.OAuth2URL(ScopeSnsapiBase, "REDIRECT_URI", "STATE", "AGENTID")

assert.Equal(t, "https://open.weixin.qq.com/connect/oauth2/authorize?appid=CORPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect", authURL)
assert.Equal(t, "https://open.weixin.qq.com/connect/oauth2/authorize?appid=CORPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_base&state=STATE&agentid=AGENTID#wechat_redirect", authURL)
}

func TestQRCodeAuthURL(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions corp/corpgroup/corpgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package corpgroup
import (
"encoding/json"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type CorpInfo struct {
Expand Down
4 changes: 2 additions & 2 deletions corp/corpgroup/cropgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
"github.com/stretchr/testify/assert"
)

Expand Down
4 changes: 2 additions & 2 deletions corp/externalcontact/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"path/filepath"
"strconv"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type MediaType string
Expand Down
6 changes: 3 additions & 3 deletions corp/externalcontact/attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
"github.com/liniu/gochat/wx"
)

func TestUploadAttachment(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions corp/externalcontact/contact_way.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package externalcontact
import (
"encoding/json"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type ContactType int
Expand Down
4 changes: 2 additions & 2 deletions corp/externalcontact/contact_way_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
)

func TestListFollowUser(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions corp/externalcontact/customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package externalcontact
import (
"encoding/json"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type ExternalContact struct {
Expand Down
4 changes: 2 additions & 2 deletions corp/externalcontact/customer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
)

func TestList(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions corp/externalcontact/groupchat.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package externalcontact
import (
"encoding/json"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type GroupChatOwnerFilter struct {
Expand Down
4 changes: 2 additions & 2 deletions corp/externalcontact/groupchat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
)

func TestListGroupChat(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions corp/externalcontact/groupmsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package externalcontact
import (
"encoding/json"

"github.com/shenghui0779/gochat/event"
"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/event"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

// ChatType 群发任务的类型
Expand Down
6 changes: 3 additions & 3 deletions corp/externalcontact/groupmsg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/event"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/event"
"github.com/liniu/gochat/mock"
)

func TestAddMsgTemplate(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions corp/externalcontact/intercept_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package externalcontact
import (
"encoding/json"

"github.com/shenghui0779/gochat/urls"
"github.com/shenghui0779/gochat/wx"
"github.com/liniu/gochat/urls"
"github.com/liniu/gochat/wx"
)

type ExtraRule struct {
Expand Down
4 changes: 2 additions & 2 deletions corp/externalcontact/intercept_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/shenghui0779/gochat/corp"
"github.com/shenghui0779/gochat/mock"
"github.com/liniu/gochat/corp"
"github.com/liniu/gochat/mock"
)

func TestAddInterceptRule(t *testing.T) {
Expand Down
Loading

0 comments on commit 6bdcf67

Please sign in to comment.