Documentation ¶
Overview ¶
网页授权流程分为四步:
整体流程 第一步: 网页后端发现用户未登录,请求身份验证; 第二步: 用户登录后,开放平台生成登录预授权码,302跳转至重定向地址; 第三步: 网页后端调用获取登录用户身份校验登录预授权码合法性,获取到用户身份; 第四步: 如需其他用户信息,网页后端可调用获取用户信息(身份验证)。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRedirectUri ¶
请求身份验证
应用请求用户身份验证时,需按如下方式构造登录链接,并引导用户跳转至此链接。飞书客户端内用户免登,系统浏览器内用户需完成扫码登录。登录成功后会生成登录预授权码 code,并作为参数重定向到重定向URL。
See: https://open.feishu.cn/document/ukTMukTMukTM/ukzN4UjL5cDO14SO3gTN
Types ¶
type AccessToken ¶
type AccessToken struct { Code int `json:"code"` Msg string `json:"msg"` Data struct { AccessToken string `json:"access_token"` AvatarURL string `json:"avatar_url"` AvatarThumb string `json:"avatar_thumb"` AvatarMiddle string `json:"avatar_middle"` AvatarBig string `json:"avatar_big"` ExpiresIn int `json:"expires_in"` Name string `json:"name"` EnName string `json:"en_name"` OpenID string `json:"open_id"` TenantKey string `json:"tenant_key"` RefreshExpiresIn int `json:"refresh_expires_in"` RefreshToken string `json:"refresh_token"` TokenType string `json:"token_type"` } `json:"data"` }
func GetAccessToken ¶
func GetAccessToken(app_access_token string, code string) (accessTokenResp AccessToken, err error)
获取登录用户身份
通过此接口获取登录预授权码 code 对应的登录用户身份。
See: https://open.feishu.cn/document/ukTMukTMukTM/uEDO4UjLxgDO14SM4gTN
POST https://open.feishu.cn/open-apis/authen/v1/access_token
func RefreshAccessToken ¶
func RefreshAccessToken(app_access_token string, refresh_token string) (accessTokenResp AccessToken, err error)
刷新 access_token
该接口用于在 access_token 过期时用 refresh_token 重新获取 access_token。此时会返回新的 refresh_token,再次刷新 access_token 时需要使用新的 refresh_token。
See: https://open.feishu.cn/document/ukTMukTMukTM/uQDO4UjL0gDO14CN4gTN
POST https://open.feishu.cn/open-apis/authen/v1/refresh_access_token
type Session ¶
type Session struct { Code int `json:"code"` Msg string `json:"msg"` Data struct { UID string `json:"uid"` OpenID string `json:"open_id"` UnionID string `json:"union_id"` SessionKey string `json:"session_key"` TenantKey string `json:"tenant_key"` EmployeeID string `json:"employee_id"` TokenType string `json:"token_type"` AccessToken string `json:"access_token"` ExpiresIn int `json:"expires_in"` RefreshToken string `json:"refresh_token"` } `json:"data"` }
func Code2Session ¶
code2session
本接口应在后端服务器调用
通过 login 接口获取到登录凭证后,开发者可以通过服务器发送请求的方式获取 session_key 和 openId
See: https://open.feishu.cn/document/uYjL24iN/ukjM04SOyQjL5IDN
POST https://open.feishu.cn/open-apis/mina/v2/tokenLoginValidate
type UserInfo ¶
type UserInfo struct { Code int `json:"code"` Msg string `json:"msg"` Data struct { Name string `json:"name"` AvatarURL string `json:"avatar_url"` AvatarThumb string `json:"avatar_thumb"` AvatarMiddle string `json:"avatar_middle"` AvatarBig string `json:"avatar_big"` Email string `json:"email"` UserID string `json:"user_id"` Mobile string `json:"mobile"` Status int `json:"status"` } `json:"data"` }
func GetUserInfo ¶
获取用户信息(身份验证)
此接口仅用于获取登录用户的信息。调用此接口需要在 Header 中带上 user_access_token。
See: https://open.feishu.cn/document/ukTMukTMukTM/uIDO4UjLygDO14iM4gTN