C# Класс OAuth2.Client.OAuth2Client

Base class for any OAuth2 client implementation within this library. Essentially descendants of this class are intended for doing user authentication using certain third-party service.
Standard flow is: - client instance generates URI for login link (__C - hosting app renders page with login link using aforementioned URI - user clicks login link - this leads to redirect to third-party service site - user does authentication and allows app access his/her basic information - third-party service redirects user to hosting app - hosting app reads user information using GetUserInfo method on callback
Наследование: IClient
Показать файл Открыть проект

Открытые методы

Метод Описание
GetLoginLinkUri ( string state = null ) : string

Returns URI of service which should be called in order to start authentication process. This URI should be used for rendering login link.

Any additional information that will be posted back by service.

GetUserInfo ( NameValueCollection parameters ) : OAuth2.Models.UserInfo

Obtains user information using OAuth2 service and data provided via callback request.

Защищенные методы

Метод Описание
AfterGetAccessToken ( IRestResponse response ) : void

Called just after obtaining response with access token from service. Allows to read extra data returned along with access token.

BeforeGetUserInfo ( IRestRequest request ) : void

Called just before issuing request to service when everything is ready. Allows to add extra parameters to request or do any other needed preparations.

OAuth2Client ( IRequestFactory factory, IClientConfiguration configuration ) : System

Initializes a new instance of the OAuth2Client class.

ParseUserInfo ( string content ) : OAuth2.Models.UserInfo

Should return parsed UserInfo using content received from provider.

Приватные методы

Метод Описание
GetAccessToken ( NameValueCollection parameters ) : string

Issues query for access token and parses response.

GetUserInfo ( string accessToken ) : OAuth2.Models.UserInfo

Obtains user information using provider API.

Описание методов

AfterGetAccessToken() защищенный Метод

Called just after obtaining response with access token from service. Allows to read extra data returned along with access token.
protected AfterGetAccessToken ( IRestResponse response ) : void
response IRestResponse
Результат void

BeforeGetUserInfo() защищенный Метод

Called just before issuing request to service when everything is ready. Allows to add extra parameters to request or do any other needed preparations.
protected BeforeGetUserInfo ( IRestRequest request ) : void
request IRestRequest
Результат void

GetLoginLinkUri() публичный Метод

Returns URI of service which should be called in order to start authentication process. This URI should be used for rendering login link.
Any additional information that will be posted back by service.
public GetLoginLinkUri ( string state = null ) : string
state string
Результат string

GetUserInfo() публичный Метод

Obtains user information using OAuth2 service and data provided via callback request.
public GetUserInfo ( NameValueCollection parameters ) : OAuth2.Models.UserInfo
parameters System.Collections.Specialized.NameValueCollection Callback request payload (parameters).
Результат OAuth2.Models.UserInfo

OAuth2Client() защищенный Метод

Initializes a new instance of the OAuth2Client class.
protected OAuth2Client ( IRequestFactory factory, IClientConfiguration configuration ) : System
factory IRequestFactory The factory.
configuration IClientConfiguration The configuration.
Результат System

ParseUserInfo() защищенный абстрактный Метод

Should return parsed UserInfo using content received from provider.
protected abstract ParseUserInfo ( string content ) : OAuth2.Models.UserInfo
content string The content which is received from provider.
Результат OAuth2.Models.UserInfo