Skip to content

Commit

Permalink
fix: WeChat export HTTPClient markbates#574
Browse files Browse the repository at this point in the history
  • Loading branch information
ShuQingZai committed Aug 15, 2024
1 parent 5d0f51e commit 492c562
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions providers/wechat/wechat.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
"net/url"
"time"

"github.com/markbates/goth"
"golang.org/x/oauth2"

"github.com/markbates/goth"
)

const (
Expand All @@ -24,12 +25,14 @@ const (
type Provider struct {
providerName string
config *oauth2.Config
httpClient *http.Client

ClientID string
ClientSecret string
RedirectURL string
Lang WechatLangType

HTTPClient *http.Client

AuthURL string
TokenURL string
ProfileURL string
Expand Down Expand Up @@ -71,7 +74,7 @@ func (p *Provider) SetName(name string) {
}

func (p *Provider) Client() *http.Client {
return goth.HTTPClientWithFallBack(p.httpClient)
return goth.HTTPClientWithFallBack(p.HTTPClient)
}

// Debug is a no-op for the wechat package.
Expand Down Expand Up @@ -135,20 +138,16 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
}

func newConfig(provider *Provider) *oauth2.Config {
c := &oauth2.Config{
return &oauth2.Config{
ClientID: provider.ClientID,
ClientSecret: provider.ClientSecret,
RedirectURL: provider.RedirectURL,
Endpoint: oauth2.Endpoint{
AuthURL: provider.AuthURL,
TokenURL: provider.TokenURL,
},
Scopes: []string{},
Scopes: []string{ScopeSnsapiLogin},
}

c.Scopes = append(c.Scopes, ScopeSnsapiLogin)

return c
}

func userFromReader(r io.Reader, user *goth.User) error {
Expand Down

0 comments on commit 492c562

Please sign in to comment.