Class: App
Fanbook 第三方应用。
Constructors
new App()
new App(
clientId,clientSecret,redirectUrl,options?):App
Parameters
| Parameter | Type | Description |
|---|---|---|
clientId | string | OAuth 2.0 流程中的 client id。 |
clientSecret | string | OAuth 2.0 流程中的 client secret。 |
redirectUrl | string | OAuth 2.0 流程中的 redirect url。 |
options? | AppOptions | 配置项。 |
Returns
Defined in
Properties
axios
readonlyaxios:Axios
请求使用的 axios 实例。
默认配置:
baseURL:https://a1.fanbook.mobi/openheaders:Authorization: 用户名为 clientId,密码为 clientSecretContent-Type:application/x-www-form-urlencoded
Defined in
clientId
readonlyclientId:string
OAuth 2.0 流程中的 client id。
Defined in
clientSecret
readonlyclientSecret:string
OAuth 2.0 流程中的 client secret。
Defined in
redirectUrl
readonlyredirectUrl:string
OAuth 2.0 流程中的 redirect url。
Defined in
Methods
codeToToken()
codeToToken(
code):Promise<OAuth2Session>
OAuth 2.0 流程中,通过 authorization code 获取 access token。
Parameters
| Parameter | Type | Description |
|---|---|---|
code | string | authorization code |
Returns
Promise<OAuth2Session>
获取结果
Defined in
getUser()
getUser(
accessToken):Promise<User>
获取用户基本信息。
Parameters
| Parameter | Type | Description |
|---|---|---|
accessToken | string | OAuth 2.0 流程中的 access token |
Returns
Promise<User>
access token 对应的用户的基本信息
Defined in
listUserGuild()
listUserGuild(
accessToken):Promise<Guild[]>
获取用户所在的服务器。
Parameters
| Parameter | Type | Description |
|---|---|---|
accessToken | string | OAuth 2.0 流程中的 access token |
Returns
Promise<Guild[]>
access token 对应的用户所在的服务器列表
Defined in
refreshToken()
refreshToken(
refreshToken):Promise<OAuth2Session>
OAuth 2.0 流程中,刷新 access token。
Parameters
| Parameter | Type | Description |
|---|---|---|
refreshToken | string | OAuth 2.0 流程中的 refresh token |
Returns
Promise<OAuth2Session>
刷新结果