Class IdentityService
Provides methods to query an identity's profile.
Inheritance
Inherited Members
Namespace: TheIdentityHub
Assembly: TheIdentityHub.dll
Syntax
public sealed class IdentityService
Constructors
IdentityService()
Initializes a new instance of the IdentityService class.
Declaration
public IdentityService()
IdentityService(String, Uri)
Initializes a new instance of the IdentityService class.
Declaration
public IdentityService(string clientId, Uri baseUrl)
Parameters
Type | Name | Description |
---|---|---|
System.String | clientId | The client identifier. |
System.Uri | baseUrl | The base URL. |
IdentityService(String, Uri, String)
Initializes a new instance of the IdentityService class.
Declaration
public IdentityService(string clientId, Uri baseUrl, string clientSecret)
Parameters
Type | Name | Description |
---|---|---|
System.String | clientId | The client identifier. |
System.Uri | baseUrl | The base URL. |
System.String | clientSecret | The client secret. |
IdentityService(String, Uri, String, String)
Initializes a new instance of the IdentityService class.
Declaration
public IdentityService(string clientId, Uri baseUrl, string clientSecret, string accessToken)
Parameters
Type | Name | Description |
---|---|---|
System.String | clientId | The client identifier. |
System.Uri | baseUrl | The base URL. |
System.String | clientSecret | The client secret. |
System.String | accessToken | The access token. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | clientId or baseUrl or accessToken |
System.ArgumentException | Invalid baseUrl |
Properties
BaseUrl
Gets the base URL.
Declaration
public Uri BaseUrl { get; }
Property Value
Type | Description |
---|---|
System.Uri | The base URL. |
ClientId
Gets the client identifier.
Declaration
public string ClientId { get; }
Property Value
Type | Description |
---|---|
System.String | The client identifier. |
ClientSecret
Gets the client secret.
Declaration
public string ClientSecret { get; }
Property Value
Type | Description |
---|---|
System.String | The client secret. |
Methods
AddAccount(AccountProvider, String)
Adds an account to the current identity.
Declaration
public void AddAccount(AccountProvider accountProvider, string returnUrl)
Parameters
Type | Name | Description |
---|---|---|
AccountProvider | accountProvider | The account provider. |
System.String | returnUrl | The return URL. |
DeleteProfileAsync()
Deletes the profile.
Declaration
public async Task DeleteProfileAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
GetAccessTokenDataAsync()
Gets the access token data.
Declaration
public async Task<TokenInfo> GetAccessTokenDataAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TokenInfo> |
GetAccountProvidersAsync()
Gets the account providers.
Declaration
public async Task<AccountProvider[]> GetAccountProvidersAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<AccountProvider[]> | The account providers. |
GetAccountProvidersAsync(Int64)
Gets the account providers.
Declaration
public async Task<AccountProvider[]> GetAccountProvidersAsync(long identityId)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | identityId |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<AccountProvider[]> | The account providers. |
GetProfileAsync()
Gets the profile.
Declaration
public async Task<Profile> GetProfileAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Profile> | The profile. |
GetProfileAsync(Int64)
Gets the profile asynchronous.
Declaration
public async Task<Profile> GetProfileAsync(long identityId)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | identityId | The identity identifier. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Profile> | The profile. |
GetRolesAsync()
Gets the roles asynchronous.
Declaration
public async Task<Role[]> GetRolesAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Role[]> | The roles. |
GetRolesAsync(Int64)
Gets the roles asynchronous.
Declaration
public async Task<Role[]> GetRolesAsync(long identityId)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | identityId | The identity identifier. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Role[]> | The roles. |
RequireTwoFactorAuthenticationAsync(String)
Requires two-factor authentication for the current identity.
Declaration
public Task<bool> RequireTwoFactorAuthenticationAsync(string returnUrl)
Parameters
Type | Name | Description |
---|---|---|
System.String | returnUrl | The url to return to after the two factor authentication is performed. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | A task representing |
Remarks
If the identity has not performed two factor authentication, the method will redirect the browser to a page to let the user perform two factor authentication.
UpdateProfileAsync(Profile)
Updates the profile asynchronous.
Declaration
public Task UpdateProfileAsync(Profile profile)
Parameters
Type | Name | Description |
---|---|---|
Profile | profile | The profile to update. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |