Class Client
OAuthの認可を行うクライアント
Implements
Inherited Members
Namespace: Pixiv.VroidSdk.Oauth
Assembly: Pixiv.VroidSdk.dll
Syntax
public sealed class Client : IApiRequestable
Constructors
Client(ISdkConfig, IHttpConnectionDriver)
コンストラクタ
Declaration
public Client(ISdkConfig config, IHttpConnectionDriver driver)
Parameters
| Type | Name | Description |
|---|---|---|
| ISdkConfig | config | VRoid SDKの設定 |
| IHttpConnectionDriver | driver | HTTPリクエストを行うIHttpConnectionDriver |
Client(ISdkConfig, SynchronizationContext)
コンストラクタ
Declaration
public Client(ISdkConfig config, SynchronizationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| ISdkConfig | config | VRoid SDKの設定 |
| SynchronizationContext | context | コールバックを呼び出すSynchronizationContext |
Properties
State
認可リクエストを行ったユーザーが、リダイレクトコールバックを受け取るユーザーと同一か確認するための値
Declaration
public string State { get; }
Property Value
| Type | Description |
|---|---|
| String |
Remarks
CSRF対策のため
Methods
ApiConnection(String, IHttpParam, IDictionary<String, String>, Nullable<Int32>)
APIリクエストを実行するためのIHttpConnectionを返す
Declaration
public IHttpConnection ApiConnection(string requestPath, IHttpParam param = null, IDictionary<string, string> header = null, int? timeout = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | requestPath | リクエスト先のパス |
| IHttpParam | param | HTTPリクエストパラメータ |
| IDictionary<String, String> | header | HTTPリクエストヘッダ |
| Nullable<Int32> | timeout | HTTPリクエストのタイムアウト時間(秒) |
Returns
| Type | Description |
|---|---|
| IHttpConnection | APIリクエストを実行するIHttpConnection |
AuthCode(IBrowserControllable, Action<Account>, Action<Exception>)
認可コードを取得するIStrategyを作成する
Declaration
public IStrategy AuthCode(IBrowserControllable browser, Action<Account> onAccountAuth, Action<Exception> onFailed)
Parameters
| Type | Name | Description |
|---|---|---|
| IBrowserControllable | browser | ログインするブラウザ |
| Action<Account> | onAccountAuth | 成功コールバック |
| Action<Exception> | onFailed | 失敗コールバック |
Returns
| Type | Description |
|---|---|
| IStrategy | 認可コードを取得するIStrategy |
Remarks
onAccountAuthとonFailedはGetTokenAsync()を実行したタイミングで呼び出される
DeviceCode(Action<DeviceAuthorization>, Action<Account>, Action<Exception>)
デバイス認証のための情報を取得するIStrategyを作成する
Declaration
public IStrategy DeviceCode(Action<DeviceAuthorization> onGetUserCode, Action<Account> onAccountAuth, Action<Exception> onFailed)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<DeviceAuthorization> | onGetUserCode | |
| Action<Account> | onAccountAuth | 成功コールバック |
| Action<Exception> | onFailed | 失敗コールバック |
Returns
| Type | Description |
|---|---|
| IStrategy | 認可コードを取得するIStrategy |
Remarks
onAccountAuthとonFailedはGetTokenAsync()を実行したタイミングで呼び出される
ForceRefreshCode(Action<Account>, Action<Exception>)
APIアクセストークンを強制的に再発行する
Declaration
public IStrategy ForceRefreshCode(Action<Account> onAccountAuth, Action<Exception> onFailed)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<Account> | onAccountAuth | トークンの再発行に成功した |
| Action<Exception> | onFailed | トークンの再発行に失敗した |
Returns
| Type | Description |
|---|---|
| IStrategy | APIアクセストークンを再発行するIStrategyを返す |
IsAccessTokenExpired()
アクセストークンが期限切れかどうか
Declaration
public bool IsAccessTokenExpired()
Returns
| Type | Description |
|---|---|
| Boolean | 期限切れであれば |
IsAccountAccessTokenExist()
アクセストークンが取得可能か
Declaration
public bool IsAccountAccessTokenExist()
Returns
| Type | Description |
|---|---|
| Boolean | アクセストークンが取得可能な場合は |
IsAccountFileExist()
アカウントを記録したファイルが存在するか
Declaration
public bool IsAccountFileExist()
Returns
| Type | Description |
|---|---|
| Boolean | 存在すれば |
Login(IBrowserControllable, Action<Account>, Action<Exception>)
ログイン
Declaration
public void Login(IBrowserControllable browser, Action<Account> onSuccess, Action<Exception> onFailed)
Parameters
| Type | Name | Description |
|---|---|---|
| IBrowserControllable | browser | ログインに使用するブラウザ |
| Action<Account> | onSuccess | 成功コールバック |
| Action<Exception> | onFailed | 失敗コールバック |
LoginWithDeviceFlow(Action<DeviceAuthorization>, Action<Account>, Action<Exception>)
DeviceFlowによるログイン
Declaration
public void LoginWithDeviceFlow(Action<DeviceAuthorization> onGetUserCode, Action<Account> onSuccess, Action<Exception> onFailed)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<DeviceAuthorization> | onGetUserCode | |
| Action<Account> | onSuccess | 成功コールバック |
| Action<Exception> | onFailed | 失敗コールバック |
RefreshCode(Action<Account>, Action<Exception>)
トークンリフレッシュを行う、IStrategyを返す
Declaration
public IStrategy RefreshCode(Action<Account> onAccountAuth, Action<Exception> onFailed)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<Account> | onAccountAuth | |
| Action<Exception> | onFailed |
Returns
| Type | Description |
|---|---|
| IStrategy | トークンリフレッシュを行う、IStrategy |
ReleaseAuthorizedAccount()
デバイスに保存しているアカウント情報を削除する
Declaration
public void ReleaseAuthorizedAccount()