C# Class Box.V2.Auth.AuthRepository

Default auth repository implementation that will manage the life cycle of the authentication tokens. This class can be extended to provide your own token management implementation by overriding the virtual methods
Inheritance: IAuthRepository
Show file Open project: box/box-windows-sdk-v2 Class Usage Examples

Protected Properties

Property Type Description
_config IBoxConfig
_converter IBoxConverter
_service IBoxService

Public Methods

Method Description
AuthRepository ( IBoxConfig boxConfig, IBoxService boxService, IBoxConverter converter ) : Box.V2.Config

Instantiates a new AuthRepository.

AuthRepository ( IBoxConfig boxConfig, IBoxService boxService, IBoxConverter converter, OAuthSession session ) : Box.V2.Config

Instantiates a new AuthRepository

AuthenticateAsync ( string authCode ) : Task

Authenticates the session by exchanging the provided auth code for a Access/Refresh token pair

LogoutAsync ( ) : Task

Logs the current session out by invalidating the current Access/Refresh tokens

RefreshAccessTokenAsync ( string accessToken ) : Task

Refreshes the session by exchanging the access token for a new Access/Refresh token pair. In general, this method should not need to be called explicitly, as an automatic refresh is invoked when the SDK detects that the tokens have expired.

Protected Methods

Method Description
ExchangeAuthCode ( string authCode ) : Task

Performs the authentication request using the provided auth code

ExchangeRefreshToken ( string refreshToken ) : Task

Performs the refresh request using the provided refresh token

InvalidateTokens ( string accessToken ) : Task

Performs the revoke request using the provided access token. This will invalidate both the access and refresh tokens

OnSessionAuthenticated ( OAuthSession session ) : void

Allows sub classes to invoke the SessionAuthenticated event.

OnSessionInvalidated ( ) : void

Allows sub classes to invoke the SessionInvalidated event

Method Details

AuthRepository() public method

Instantiates a new AuthRepository.
public AuthRepository ( IBoxConfig boxConfig, IBoxService boxService, IBoxConverter converter ) : Box.V2.Config
boxConfig IBoxConfig The Box configuration that should be used.
boxService IBoxService The Box service that will be used to make the requests.
converter IBoxConverter How requests/responses will be serialized/deserialized respectively.
return Box.V2.Config

AuthRepository() public method

Instantiates a new AuthRepository
public AuthRepository ( IBoxConfig boxConfig, IBoxService boxService, IBoxConverter converter, OAuthSession session ) : Box.V2.Config
boxConfig IBoxConfig The Box configuration that should be used
boxService IBoxService The Box service that will be used to make the requests
converter IBoxConverter How requests/responses will be serialized/deserialized respectively
session OAuthSession The current authenticated session
return Box.V2.Config

AuthenticateAsync() public method

Authenticates the session by exchanging the provided auth code for a Access/Refresh token pair
public AuthenticateAsync ( string authCode ) : Task
authCode string Authorization Code. The authorization code is only valid for 30 seconds.
return Task

ExchangeAuthCode() protected method

Performs the authentication request using the provided auth code
protected ExchangeAuthCode ( string authCode ) : Task
authCode string Authorization Code. The authorization code is only valid for 30 seconds.
return Task

ExchangeRefreshToken() protected method

Performs the refresh request using the provided refresh token
protected ExchangeRefreshToken ( string refreshToken ) : Task
refreshToken string Refresh token used to exchange for a new access token. Each refresh_token is valid for one use in 60 days. Every time you get a new access_token by using a refresh_token, we reset your timer for the 60 day period and hand you a new refresh_token
return Task

InvalidateTokens() protected method

Performs the revoke request using the provided access token. This will invalidate both the access and refresh tokens
protected InvalidateTokens ( string accessToken ) : Task
accessToken string The access token to invalidate
return Task

LogoutAsync() public method

Logs the current session out by invalidating the current Access/Refresh tokens
public LogoutAsync ( ) : Task
return Task

OnSessionAuthenticated() protected method

Allows sub classes to invoke the SessionAuthenticated event.
protected OnSessionAuthenticated ( OAuthSession session ) : void
session OAuthSession Authenticated session.
return void

OnSessionInvalidated() protected method

Allows sub classes to invoke the SessionInvalidated event
protected OnSessionInvalidated ( ) : void
return void

RefreshAccessTokenAsync() public method

Refreshes the session by exchanging the access token for a new Access/Refresh token pair. In general, this method should not need to be called explicitly, as an automatic refresh is invoked when the SDK detects that the tokens have expired.
public RefreshAccessTokenAsync ( string accessToken ) : Task
accessToken string The access token to refresh.
return Task

Property Details

_config protected property

protected IBoxConfig _config
return IBoxConfig

_converter protected property

protected IBoxConverter _converter
return IBoxConverter

_service protected property

protected IBoxService _service
return IBoxService