auth

package
v0.0.0-...-8077ce6 Latest Latest
Warning

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

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

Documentation

Overview

Package auth 登录

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RespCode2Session

type RespCode2Session struct {
	microapp.Error

	Openid          string `json:"openid"`           // 用户在当前小程序的 ID,如果请求时有 code 参数才会返回
	SessionKey      string `json:"session_key"`      // 会话密钥,如果请求时有 code 参数才会返回
	AnonymousOpenid string `json:"anonymous_openid"` // 匿名用户在当前小程序的 ID,如果请求时有 anonymous_code 参数才会返回
}

code2Session

通过login接口获取到登录凭证后,开发者可以通过服务器发送请求的方式获取 session_key 和 openId。

See: https://microapp.bytedance.com/docs/zh-CN/mini-app/develop/server/log-in/code-2-session

GET https://developer.toutiao.com/api/apps/jscode2session

RespCode2Session struct

func Code2Session

func Code2Session(ctx *microapp.MicroApp, params url.Values) (RespCode2Session, error)
Example
package main

import (
	"fmt"
	"net/url"

	"github.com/jackluo2012/microapp"
	"github.com/jackluo2012/microapp/apis/auth"
)

func main() {
	var ctx *microapp.MicroApp

	params := url.Values{}
	resp, err := auth.Code2Session(ctx, params)

	fmt.Println(resp, err)
}
Output:

Jump to

Keyboard shortcuts

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