Hubtel Core Authentication Library
The hubtel_auth
is a package hosted on azure to enhance easy and quick integration of hubtel onboarding/login process. It also supports QR login on hubtel web apps from the mobile platform.
Getting Started
To add the hubtel_auth
package to your project, Add the code below to your pubspec.yaml
file.
NB: ref
represents the version number of the package being used and subjected to change.
hubtel_auth:
git:
url: [email protected]:v3/hubtel/Mobile-Apps/Platform-Library-Flutter-Hubtel-Auth
ref: 1.0.9
Usage
Requirement
appId
: An identifier for the application using the auth.
Implementation
To implement the hubtel authentication library, you need to initialize the HubtelAuth
class to access its instance methods.
Methods
startLogin
: This method starts the login process. It returns future that resolves to return LoginResult, hence must be awaited to get the result.
_openLogin() async {
// Start the login with the method below. This method returns a value of type LoginResult when the future resolves.
final completedLogin = await HubtelAuth().startLogin("{Pass AppId here}");
}
startWebQRLogin
: This method starts the QR login process. It returns a future that resolves to return a boolean the specifies whether the login process failed or succeeded. It takes a param of type WebQRLoginStarter, which encapsulates the appId, mobileNumber and bearerToken of the user.
async startQR(){
final result = await _hubtelAuthPlugin.startWebQRLogin(
WebQRLoginStarter(
appId: "d998d013-d6f5-4ee9-8059-867bd44f6e52",
phoneNumber: "233*******39",
bearerToken: "Bearer Token",
),
);
//The future resolves to produce a boolean
}
LoginResult
This is an object the startLogin method returns back to the user of the SDK and it encapsulates the mobile number and the token of the user who logged in.
Parameter | Description |
---|---|
mobileNumber | A string that represents the mobile number of the user. |
token | A string that represents the bearer token of the user. |
WebQRLoginStarter
This is an object that encapsulates the parameters being passed to the QR login endpoint.
Parameter | Description |
---|---|
appId | A string that represents the app using the SDK. |
phoneNumber | A string that represents the mobile number of the user performing the QR Login. |
bearerToken | A string that represents the auth token of the user performing the QR Login. |
CHAT SAMMIAT