openauth

package module
v0.0.0-...-ae6c848 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

README

openauth

主流第三方登录Token授权校验.

功能

用于客户端第三方授权登录后,服务器进行进一步的授权校验。

平台
  • QQ
  • 微信
  • 新浪
  • 小米
  • Google
  • Facebook
使用
go get github.com/usthooz/openauth
Example
package openauth

import (
	"github.com/usthooz/openauth/facebook"
	"github.com/usthooz/openauth/google"
	"testing"
)

func TestQqAuth(t *testing.T) {
	success, err := QqAuth("", "")
	t.Logf("Success: %v, Err: %v", success, err)
}

func TestSinaAuth(t *testing.T) {
	success, err := SinaAuth("", "")
	t.Logf("Success: %v, Err: %v", success, err)
}

func TestWxAuth(t *testing.T) {
	success, err := WxAuth("", "")
	t.Logf("Success: %v, Err: %v", success, err)
}

func TestXiaomiAuth(t *testing.T) {
	success, err := XiaomiAuth("", "", "")
	t.Logf("Success: %v, Err: %v", success, err)
}

func TestGoogleVerify(t *testing.T) {
	result, err := google.GoogleVerify("", "")
	t.Logf("Success: %v, Err: %v", result, err)
}

func TestFacebookVerify(t *testing.T) {
	result, err := facebook.FacebookVerify("", "", "")
	t.Logf("Success: %v, Err: %v", result, err)
}

Documentation

Index

Constants

View Source
const (
	// QqAuthApi QQ授权api
	QqAuthApi = "https://graph.qq.com/oauth2.0/me?access_token=%s"
	// WxAuthApi 微信授权api
	WxAuthApi = "https://api.weixin.qq.com/sns/auth?access_token=%s&openid==%s"
	// SinaAuthApi 新浪授权api
	SinaAuthApi = "https://api.weibo.com/2/account/get_uid.json?access_token=%s&source=%s"
	// XiaomiAuthApi 小米授权api
	XiaomiAuthApi = "https://open.account.xiaomi.com/user/openidV2?token=%s&clientId=%s"
)

Variables

This section is empty.

Functions

func QqAuth

func QqAuth(accessToken, openId string) (bool, error)

QqAuth

func SinaAuth

func SinaAuth(accessToken, sinaUid string) (bool, error)

SinaAuth

func WxAuth

func WxAuth(accessToken, openId string) (bool, error)

WxAuth

func XiaomiAuth

func XiaomiAuth(accessToken, openId, appId string) (bool, error)

XiaomiAuth

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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