Skip to content

Class: App ​

Fanbook 第三方应用。

Constructors ​

new App() ​

new App(clientId, clientSecret, redirectUrl, options?): App

Parameters ​

ParameterTypeDescription
clientIdstringOAuth 2.0 流程中的 client id。
clientSecretstringOAuth 2.0 流程中的 client secret。
redirectUrlstringOAuth 2.0 流程中的 redirect url。
options?AppOptions配置项。

Returns ​

App

Defined in ​

src/app.ts:15

Properties ​

axios ​

readonly axios: Axios

请求使用的 axios 实例。

默认配置:

  • baseURL: https://a1.fanbook.mobi/open
  • headers:
    • Authorization: 用户名为 clientId,密码为 clientSecret
    • Content-Type: application/x-www-form-urlencoded

Defined in ​

src/app.ts:40


clientId ​

readonly clientId: string

OAuth 2.0 流程中的 client id。

Defined in ​

src/app.ts:17


clientSecret ​

readonly clientSecret: string

OAuth 2.0 流程中的 client secret。

Defined in ​

src/app.ts:19


redirectUrl ​

readonly redirectUrl: string

OAuth 2.0 流程中的 redirect url。

Defined in ​

src/app.ts:21

Methods ​

codeToToken() ​

codeToToken(code): Promise<OAuth2Session>

OAuth 2.0 流程中,通过 authorization code 获取 access token。

Parameters ​

ParameterTypeDescription
codestringauthorization code

Returns ​

Promise<OAuth2Session>

获取结果

Defined in ​

src/app.ts:47


getUser() ​

getUser(accessToken): Promise<User>

获取用户基本信息。

Parameters ​

ParameterTypeDescription
accessTokenstringOAuth 2.0 流程中的 access token

Returns ​

Promise<User>

access token 对应的用户的基本信息

Defined in ​

src/app.ts:73


listUserGuild() ​

listUserGuild(accessToken): Promise<Guild[]>

获取用户所在的服务器。

Parameters ​

ParameterTypeDescription
accessTokenstringOAuth 2.0 流程中的 access token

Returns ​

Promise<Guild[]>

access token 对应的用户所在的服务器列表

Defined in ​

src/app.ts:86


refreshToken() ​

refreshToken(refreshToken): Promise<OAuth2Session>

OAuth 2.0 流程中,刷新 access token。

Parameters ​

ParameterTypeDescription
refreshTokenstringOAuth 2.0 流程中的 refresh token

Returns ​

Promise<OAuth2Session>

刷新结果

Defined in ​

src/app.ts:60

Released under the MIT License.