Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TokenStorage 和 Token 应该怎么初始化? #242

Open
Michael2008S opened this issue Oct 26, 2018 · 0 comments
Open

TokenStorage 和 Token 应该怎么初始化? #242

Michael2008S opened this issue Oct 26, 2018 · 0 comments

Comments

@Michael2008S
Copy link
Contributor

Michael2008S commented Oct 26, 2018

type Client struct {
	Endpoint Endpoint

	// TokenStorage 和 Token 两个字段正常情况下只用指定一个, 如果两个同时被指定了, 优先使用 TokenStorage
	TokenStorage TokenStorage
	Token        *Token // Client 自动将最新的 Token 更新到此字段, 不管 Token 字段一开始是否被指定!!!

	HttpClient *http.Client // 如果 HttpClient == nil 则默认用 util.DefaultHttpClient
}

这里的 TokenStorage 和 Token 应该怎么初始化?

func (s *Service) WxqrLogin(c echo.Context, code, state, fromurl string) {
	oauth2Endpoint := openoauth2.NewEndpoint(s.cfgWx.WxOpenAppid, s.cfgWx.WxOpenSid)

	oauth2Client := oauth2.Client{oauth2Endpoint,?,?,nil}

	token, err := oauth2Client.ExchangeToken(code)
	if err != nil {
		return
	}
	userinfo, err := openoauth2.GetUserInfo(token.AccessToken, token.OpenId, "", nil)

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant