User Guide: SDKs > .NET (Visual Studio) SDK > Login with provider type as Basic
Invoking an Identity Service
Perform the following steps to invoke an identity service.
- Login with provider type as Basic
- Get Backend Token
- User Profile
- Get Provider Name
- Get Provider Type
- Logout
Note: The .NET SDK does not support the Custom Auth Identity Service.
The .NET SDK does not support the OAuth/SAML Identity Service.
Login with provider type as Basic
To login, first use the SDK class GetIdentityService() method to retrieve the IdentityService. Then log in with the login() method of the IdentityService class.
GetIdentityService
The GetIdentityService method retrieves an IdentityService object with the specified provider name.
Signature
Input Parameters
providerName
The name of the provider.
Return Values
Returns an IdentityService instance.
Exceptions
System.Exception is thrown when not initialized or the service is not defined.
Example
When you have an IdentityService object, use the Login method of the IdentityService class to login.
Login
The Login method will login the user with the given credentials. This method may take several seconds to execute, so it is available as either a synchronous and asynchronous call.
Note: The .NET SDK does not support multilogin, offfline login, or SSO.
Signature
Synchronous
Asynchronous
Input Parameters
userId
The user name. This value cannot be null.
password
The user’s password. This value cannot be null.
headers
HTTP Request header key value pairs. (Optional)
parameters
HTTP Request parameter key value pairs. (Optional)
Return Values
Returns the claims token value if the login is successful.
Remarks
If the provider is Volt MX, parameters userID and password must not be null or empty.
Exceptions
A Volt MX FoundryException is thrown if the provider is Volt MX and userID or password are empty or null.
Example
Synchronous
Asynchronous
Get Backend Token
Use the IdentityService class method GetBackendToken() to get the provider datasource token.
GetBackendToken
The GetBackendToken method fetches the provider datasource token. This method may take several seconds to execute so it is available as both a synchronous and asynchronous call.
Signature
Synchronous
Asynchronous
Input Parameters
fromServer
Flag to force fetch from server only.
parameters
HTTP request parameters.
Return Values
Returns a provider token object.
Remarks
If fromServer is true, the SDK fetches the token from the server. If fromServer is false, the SDK returns the token present in local storage.
Exceptions
Volt MX FoundryException is thrown if the provider claims token is invalid.
Example
Synchronous
Asynchronous
Get User Profile
Use the IdentityService class method GetProfile() to get the user profile.
GetProfile
The GetProfile method fetches the user profile. This method may take a few seconds to execute, so it is available as either a synchronous or asynchronous call.
Signature
Synchronous
Asynchronous
Input Parameters
fromServer
Flag to force fetch from server only. Default value is false.
Return Values
Returns a user profile object.
Remarks
If fromServer is true, the SDK fetches the profile from the server. If fromServer is false, the SDK returns the profile present in local storage.
Exceptions
Volt MX Foundry Exception is thrown if the provider claims token is invalid.
Example
Synchronous
Asynchronous
Get Provider Name
Use the IdentityService class Name property to get the authentication provider name.
Name
Get Provider Type
Use the IdentityService class Type property to get the authentication provider type.
Type
Logout
Use the Logout() method of the IdentityService class to logout from the service.
Logout
The Logout method is used to logout of the service. This method may take a few seconds to execute, so it is available as both a synchronous and asynchronous call.
Signature
Synchronous
Asynchronous
Input Parameters
None.
Return Values
Returns true if the logout is successful.
Exceptions
Volt MX FoundryException is thrown when a web services call exception occurs.
Example
Synchronous
Asynchronous