oauth2

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

README

微信开放平台 移动应用、网站应用 微信登录功能 SDK

Documentation

Overview

微信开放平台 移动应用、网站应用 微信登录功能 SDK.

Index

Constants

View Source
const (
	LanguageZhCN = mpoauth2.LanguageZhCN
	LanguageZhTW = mpoauth2.LanguageZhTW
	LanguageEN   = mpoauth2.LanguageEN
)
View Source
const (
	SexUnknown = mpoauth2.SexUnknown
	SexMale    = mpoauth2.SexMale
	SexFemale  = mpoauth2.SexFemale
)

Variables

This section is empty.

Functions

func Auth

func Auth(accessToken, openId string, httpClient *http.Client) (valid bool, err error)

Auth 检验授权凭证 access_token 是否有效.

accessToken: 网页授权接口调用凭证
openId:      用户的唯一标识
httpClient:  如果不指定则默认为 util.DefaultHttpClient

func AuthCodeURL

func AuthCodeURL(appId, redirectURI, scope, state string) string

AuthCodeURL 生成网页授权地址.

appId:       公众号的唯一标识
redirectURI: 授权后重定向的回调链接地址
scope:       应用授权作用域
state:       重定向后会带上 state 参数, 开发者可以填写 a-zA-Z0-9 的参数值, 最多128字节

Types

type Endpoint

type Endpoint mpoauth2.Endpoint

func NewEndpoint

func NewEndpoint(AppId, AppSecret string) *Endpoint

func (*Endpoint) ExchangeTokenURL

func (p *Endpoint) ExchangeTokenURL(code string) string

func (*Endpoint) RefreshTokenURL

func (p *Endpoint) RefreshTokenURL(refreshToken string) string

type UserInfo

type UserInfo mpoauth2.UserInfo

func GetUserInfo

func GetUserInfo(accessToken, openId, lang string, httpClient *http.Client) (info *UserInfo, err error)

GetUserInfo 获取用户信息.

accessToken: 网页授权接口调用凭证
openId:      用户的唯一标识
lang:        返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语, 如果留空 "" 则默认为 zh_CN
httpClient:  如果不指定则默认为 util.DefaultHttpClient

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL