You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
595 B
24 lines
595 B
package wechat
|
|
|
|
import (
|
|
mpoauth2 "github.com/chanxuehong/wechat/mp/oauth2"
|
|
"github.com/chanxuehong/wechat/oauth2"
|
|
"hudongzhuanjia/utils/define"
|
|
)
|
|
|
|
var Endpoint = mpoauth2.NewEndpoint(define.WxAppId, define.Secret)
|
|
|
|
func GetToken(code string) (*oauth2.Token, error) {
|
|
client := oauth2.Client{
|
|
Endpoint: Endpoint,
|
|
}
|
|
return client.ExchangeToken(code)
|
|
}
|
|
|
|
func GetUserInfo(tk *oauth2.Token) (*mpoauth2.UserInfo, error) {
|
|
return mpoauth2.GetUserInfo(tk.AccessToken, tk.OpenId, "", nil)
|
|
}
|
|
|
|
func MiniAuth(code string) (*mpoauth2.Session, error) {
|
|
return mpoauth2.GetSession(Endpoint, code)
|
|
}
|