authorization

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 5 Imported by: 0

README

获取访问token

安装

go get github.com/hanguangbaihuo/sparrow_cloud_go/

注意

必须配置环境变量:
SC_MANAGE_SVC
SC_MANAGE_API

获取app_token

import (
    "github.com/hanguangbaihuo/sparrow_cloud_go/authorization"
)

func main() {
    // 注意修改函数参数为自己服务的名称和服务注册密钥
    token, err := authorization.GetAppToken("YourServiceName", "ServiceSecret")
    if err != nil {
        // handle error
    }
}

获取user_token

import (
    "github.com/hanguangbaihuo/sparrow_cloud_go/authorization"
)

func main() {
    // 注意修改函数参数为自己服务的名称和服务注册密钥,和用户ID
    token, err := authorization.GetUserToken("YourServiceName", "ServiceSecret", "user_id")
    if err != nil {
        // handle error
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAppToken

func GetAppToken(svcName string, svcSecret string) (string, error)

func GetUserToken

func GetUserToken(svcName string, svcSecret string, userID string) (string, error)

Types

type TokenData

type TokenData struct {
	Token     string `json:"token"`
	ExpiresIn int    `json:"expires_in"`
}

Jump to

Keyboard shortcuts

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