# Function: authorize

authorize(params: AuthorizeParams): Promise‹AuthorizeRes

提前向用户发起授权请求。 调用后会立刻弹窗询问用户是否同意授权小程序使用某项功能或获取用户的某些数据,但不会实际调用对应接口。 如果用户之前已经同意授权,则不会出现弹窗,直接返回成功。 更多用法详见 {@link 用户授权 (opens new window)}。

todo update the doc link above

# 参数:

属性 类型
params AuthorizeParams

AuthorizeParams

属性 类型 描述
scope string 需要获取权限的 scope,详见 {@link scope 列表 (opens new window)}
complete? Method 接口调用结束的回调函数(调用成功、失败都会执行)
fail? Method 接口调用失败的回调函数
success? Method 接口调用成功的回调函数

# 返回值:

Promise‹AuthorizeRes