Show / Hide Table of Contents

Class Client

Client to carry out OAuth authentication

Inheritance
Object
Client
Implements
IApiRequestable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Pixiv.VroidSdk.Oauth
Assembly: Pixiv.VroidSdk.dll
Syntax
public sealed class Client : IApiRequestable

Constructors

Client(ISdkConfig, IHttpConnectionDriver)

Constructor

Declaration
public Client(ISdkConfig config, IHttpConnectionDriver driver)
Parameters
Type Name Description
ISdkConfig config

VRoid SDK settings

IHttpConnectionDriver driver

IHttpConnectionDriver that carries out HTTP request

Client(ISdkConfig, SynchronizationContext)

Constructor

Declaration
public Client(ISdkConfig config, SynchronizationContext context)
Parameters
Type Name Description
ISdkConfig config

VRoid SDK settings

SynchronizationContext context

SynchronizationContext that calls callback

Properties

State

Value for checking whether the user that carried out authentication request matches the user that receives redirect callback

Declaration
public string State { get; }
Property Value
Type Description
String
Remarks

For protection against CSRF

Methods

ApiConnection(String, IHttpParam, IDictionary<String, String>, Nullable<Int32>)

Return IHttpConnection to run API request

Declaration
public IHttpConnection ApiConnection(string requestPath, IHttpParam param = null, IDictionary<string, string> header = null, int? timeout = null)
Parameters
Type Name Description
String requestPath

Request path

IHttpParam param

HTTP request parameter

IDictionary<String, String> header

HTTP request header

Nullable<Int32> timeout

HTTP request timeout time (seconds)

Returns
Type Description
IHttpConnection

IHttpConnection that runs API request

AuthCode(IBrowserControllable, Action<Account>, Action<Exception>)

Create IStrategy that gets authorization code

Declaration
public IStrategy AuthCode(IBrowserControllable browser, Action<Account> onAccountAuth, Action<Exception> onFailed)
Parameters
Type Name Description
IBrowserControllable browser

Log in browser

Action<Account> onAccountAuth

Callback on success

Action<Exception> onFailed

Callback on failure

Returns
Type Description
IStrategy

IStrategy that gets authorization code

Remarks

onAccountAuth and onFailed are called when GetTokenAsync() runs

DeviceCode(Action<DeviceAuthorization>, Action<Account>, Action<Exception>)

Create IStrategy that gets device authorization code

Declaration
public IStrategy DeviceCode(Action<DeviceAuthorization> onGetUserCode, Action<Account> onAccountAuth, Action<Exception> onFailed)
Parameters
Type Name Description
Action<DeviceAuthorization> onGetUserCode
Action<Account> onAccountAuth

Callback on success

Action<Exception> onFailed

Callback on failure

Returns
Type Description
IStrategy

IStrategy that gets authorization code

Remarks

onAccountAuth and onFailed are called when GetTokenAsync() runs

ForceRefreshCode(Action<Account>, Action<Exception>)

Forcefully reissue API access token

Declaration
public IStrategy ForceRefreshCode(Action<Account> onAccountAuth, Action<Exception> onFailed)
Parameters
Type Name Description
Action<Account> onAccountAuth

Token reissue succeeded

Action<Exception> onFailed

token reissue failed

Returns
Type Description
IStrategy

Return IStrategy that reissued API access token

IsAccessTokenExpired()

Is access token expired or not

Declaration
public bool IsAccessTokenExpired()
Returns
Type Description
Boolean

Returns true if expired

IsAccountAccessTokenExist()

Is access token available or not

Declaration
public bool IsAccountAccessTokenExist()
Returns
Type Description
Boolean

Returns true if access token is available

IsAccountFileExist()

Does file that recorded account exist or not

Declaration
public bool IsAccountFileExist()
Returns
Type Description
Boolean

Returns true if exists

Login(IBrowserControllable, Action<Account>, Action<Exception>)

Log in

Declaration
public void Login(IBrowserControllable browser, Action<Account> onSuccess, Action<Exception> onFailed)
Parameters
Type Name Description
IBrowserControllable browser

Log in browser

Action<Account> onSuccess

Callback on success

Action<Exception> onFailed

Callback on failure

LoginWithDeviceFlow(Action<DeviceAuthorization>, Action<Account>, Action<Exception>)

Login with DeviceFlow

Declaration
public void LoginWithDeviceFlow(Action<DeviceAuthorization> onGetUserCode, Action<Account> onSuccess, Action<Exception> onFailed)
Parameters
Type Name Description
Action<DeviceAuthorization> onGetUserCode
Action<Account> onSuccess

Callback on success

Action<Exception> onFailed

Callback on failure

RefreshCode(Action<Account>, Action<Exception>)

Carry out token refresh, return 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

carry out token refresh, IStrategy

ReleaseAuthorizedAccount()

Delete account data saved to device

Declaration
public void ReleaseAuthorizedAccount()

Implements

IApiRequestable
In This Article
Back to top Generated by DocFX