User Guide: SDKs > Flutter SDK > Invoking an Identity Service
Invoking an Identity Service
The following are the methods you can use for an identity service.
- Login with provider type as Basic
- Login with provider type as OAuth/SAML
- Custom OAuth Login
- Get Backend Token
- Logout
- Login Status
- User Profile
Login with provider type as Basic
// Sample code to log in using basic type provider
var voltmxSdkFlutter = VoltmxSdkFlutter();
var providerName = "<Your providerName here>";
var userName = "<Your userName here>";
var password = "<Your password here>";
voltmxSdkFlutter.loginInBackground(providerName, userName, password, onSuccess: (response) {
// Handle the success case here
}, onFailure: (response) {
// Handle the failure case here
});
Note: Call these methods only after successful completion of voltmxSdkFlutter.initializeSDK. For more details, refer to the Init method.
Important: When you select Volt MX User Repository as the identity type, the system does not allow you to provide an identity name. To use Volt MX User Repository as an authentication service, ensure that the value for
providerNamemust be set asuserstore. If you set it with any other value (for example, Volt MX User Repository, User Store, or Cloud Repository), the system throws an error.
Login with provider type as OAuth/SAML
// Sample code to log in using OAuth/SAML type provider
var voltmxSdkFlutter = VoltmxSdkFlutter();
var providerName = "<Your providerName here>";
int webviewId = 0;
voltmxSdkFlutter.doOAuthLogin(providerName, webviewId, onSuccess: (response) {
// Handle the success case here
}, onFailure: (response) {
// Handle the failure case here
});
Important: This is a synchronous method, and it displays a WebView. This method must be invoked from your main thread only.
Custom OAuth Login
// Sample code to log in using Custom OAuth/Custom Login provider
var voltmxSdkFlutter = VoltmxSdkFlutter();
var providerName = "<Your providerName here>";
Map<String, String> customTable = {
"userid": "UserId",
"password": "Password",
};
voltmxSdkFlutter.customLogin(providerName, customTable, onSuccess: (response) {
// Handle the success case here
}, onFailure: (response) {
// Handle the failure case here
});
Note: Not supported in the Web channel.
Get Backend Token
// Sample code to get backend token for provider
var voltmxSdkFlutter = VoltmxSdkFlutter();
var providerName = "<Your providerName here>";
voltmxSdkFlutter.getBackendToken(providerName, onSuccess: (response) {
// Handle the success case here
}, onFailure: (response) {
// Handle the failure case here
});
Note : This method returns a valid token only after login is successful.
Logout
// Sample code to logout from the auth service
var voltmxSdkFlutter = VoltmxSdkFlutter();
var providerName = "<Your providerName here>";
voltmxSdkFlutter.logout(providerName, onSuccess: (response) {
// Handle the success case here
}, onFailure: (response) {
// Handle the failure case here
});
Login Status
// Sample code to get the login status
var voltmxSdkFlutter = VoltmxSdkFlutter();
var providerName = "<Your providerName here>";
voltmxSdkFlutter.isLoggedIn(providerName, onSuccess: (response) {
// Handle the success case here
}, onFailure: (response) {
// Handle the failure case here
});
User Profile
// Sample code to get user profile details
var voltmxSdkFlutter = VoltmxSdkFlutter();
var providerName = "<Your providerName here>";
voltmxSdkFlutter.getUserProfile(providerName, onSuccess: (response) {
// Handle the success case here
}, onFailure: (response) {
// Handle the failure case here
});