accountgator_flutter¶
Flutter wrapper for the AccountGator embeddable web SDK.
This package loads your AccountGator web flow inside a native WebView, passes the required base64url data payload, and forwards the final accountgator:result message back to Dart.
Features¶
- Typed init payload (
AccountGatorInitData) with base64url encoding. AccountGatorSdkViewwidget to render the flow.- Dart callback (
onResult) for success, failure, and timeout outcomes. - Optional origin allowlist for message hardening.
Variables¶
| Variable | Description | Format | Source |
|---|---|---|---|
clientId |
Unique identifier for your organisation | Alphanumeric string | Provided by Credeau during onboarding |
authToken |
Secret token for API authentication | Alphanumeric string | Provided by Credeau during onboarding |
userId |
Unique identifier for an end user | Alphanumeric string | Provided by Credeau during onboarding |
mobileNumber |
End user's mobile number | Like, 9999999999 | Provided by customer during journey |
redirectUrl |
URL to redirect to post process | Like, https://yourdomain.com/redirection/path | Set by client as per requirement |
template_name |
Account Aggregator template name | Either BANK_STATEMENT_PERIODIC or BANK_STATEMENT_ONETIME |
Set by client as per requirement |
consentTemplates |
Account Aggregator template array | Either [BANK_STATEMENT_PERIODIC] or [BANK_STATEMENT_ONETIME] or both [BANK_STATEMENT_PERIODIC, BANK_STATEMENT_ONETIME] |
Set by client as per requirement |
⚠️ Note
Keep these credentials secure and never share them publicly. These credentials are unique to your organization and will be used to authenticate all API requests.
template_nameandconsent_templatesare mutually exclusive. Provideconsent_templatesfor a multi-template flow; providetemplate_namefor a single-template flow. Exactly one of the two must be present.
Quick start¶
1. Add the package¶
dependencies:
accountgator_flutter:
git:
url: https://github.com/Credeau/account-gator-flutter-sdk
ref: v1.2.0
2. Create the init payload¶
import 'package:accountgator_flutter/accountgator_flutter.dart';
final List<String> consentTemplates = <String>[
'BANK_STATEMENT_PERIODIC', 'BANK_STATEMENT_ONETIME'
];
final String templateName = 'BANK_STATEMENT_PERIODIC';
or
final String templateName = 'BANK_STATEMENT_ONETIME';
final initData = AccountGatorInitData(
clientId: 'your_client_id',
authToken: 'your_auth_token',
userId: 'user_123',
mobileNumber: '9876543210',
redirectUrl: 'https://your-app.com/accountgator/redirect',
templateName: templateName,
consentTemplates: consentTemplates
);
3. Start the AccountGator flow¶
Render AccountGatorSdkView on a screen where you want the consent journey to open:
import 'package:accountgator_flutter/accountgator_flutter.dart';
class ConsentFlowPage extends StatelessWidget {
const ConsentFlowPage({super.key});
final List<String> consentTemplates = <String>[
'BANK_STATEMENT_PERIODIC', 'BANK_STATEMENT_ONETIME'
];
final String templateName = 'BANK_STATEMENT_PERIODIC';
or
final String templateName = 'BANK_STATEMENT_ONETIME';
@override
Widget build(BuildContext context) {
final initData = AccountGatorInitData(
clientId: 'your_client_id',
authToken: 'your_auth_token',
userId: 'user_123',
mobileNumber: '9876543210',
redirectUrl: 'https://your-app.com/accountgator/redirect',
consentTemplates: consentTemplates,
templateName: templateName,
backendUrl: 'https://account-gator.credeau.com',
);
return Scaffold(
appBar: AppBar(title: const Text('AccountGator Consent')),
body: AccountGatorSdkView(
baseUrl: 'https://consent-journey.account-gator.credeau.com/',
initData: initData,
onResult: (result) {
// `result` is an `AccountGatorResult` returned by the SDK.
// Access `result.success` to know whether the consent flow completed.
// Access `result.aaSessionId` to get the AA session ID on success.
// Access `result.error` to read the failure reason, if any.
// Access `result.timeout` to check whether the journey timed out.
// Access `result.consent_handles_status` (only present when consent_templates is used)
if (result.success) {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => SuccessPage(sessionId: result.aaSessionId),
),
);
return;
}
if (result.timeout) {
_showMessage(context, 'Consent flow timed out');
return;
}
_showMessage(
context,
'Consent failed: ${result.error ?? 'Unknown error'}',
);
},
),
);
}
}
void _showMessage(BuildContext context, String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message)),
);
}
class SuccessPage extends StatelessWidget {
const SuccessPage({super.key, this.sessionId});
final String? sessionId;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Success')),
body: Center(
child: Text('AA session created: ${sessionId ?? 'Unavailable'}'),
),
);
}
}
Helpers:
toBase64UrlData()toSdkUri(baseUrl)
AccountGatorSdkView¶
Required:
baseUrlinitDataonResult
Optional:
allowedOriginsonPageStartedonPageFinishedonProgressonWebResourceErrorbackgroundColor
Output¶
When the consent journey completes, onResult returns an AccountGatorResult.
Example response:
{
"type": "accountgator:result",
"success": true,
"aa_session_id": "bd87bf398a754fe8b37786829bdc7118",
"error": null,
"timeout": false,
"origin": "https://consent-journey.account-gator.credeau.com"
}
Response fields:
success:truewhen the consent journey completes successfully.aaSessionId: Account Aggregator session ID returned after successful consent.error: Error message returned when the journey fails.nullon success.timeout:trueif the user does not complete the journey within the allowed time.origin: Web origin from which the result message was received.consent_handles_status: (json object) - Only present when consent_templates is used. An object keyed by template name, indicating which templates the user gave consent for.
consent_handles_status Structure¶
Each entry in consent_handles_status is keyed by the template name and contains:
| Field | Description |
|---|---|
consent_handle |
Unique handle for the consent request |
consent_status |
Status of the consent (see values below) |
consent_id |
Present when consent is accepted; otherwise null |
consent_status values¶
| Value | Meaning |
|---|---|
"ACCEPTED" |
User gave consent for that template; consent_id will be present |
"REJECTED" |
A failure occurred for that template (e.g. an error during the consent flow) |
"REQUESTED" |
User did not give consent for that template; consent_id is null |
Response Examples (when using consent_templates)¶
Single template:
Passing one template to consent_templates:
Response:
{
"success": "true",
"aa_session_id": "3617c94822b94d998f9bdcaefcb01e51",
"error": "null",
"timeout": "false",
"consent_handles_status": {
"BANK_STATEMENT_ONETIME": {
"consent_handle": "e0312e30-66f0-4793-8b3a-a64f109b036e",
"consent_status": "ACCEPTED",
"consent_id": "9f59c234-9050-89db-b944-bbfb549c9514"
}
}
}
Multiple templates:
Passing multiple templates to consent_templates:
Response:
{
"success": "true",
"aa_session_id": "783a8122359e4ea5a3b7eba7f8ba8d55",
"error": "null",
"timeout": "false",
"consent_handles_status": {
"BANK_STATEMENT_PERIODIC": {
"consent_handle": "dbc880e3-799e-44d8-a305-9bad846ed1be",
"consent_status": "REQUESTED",
"consent_id": null
},
"BANK_STATEMENT_ONETIME": {
"consent_handle": "ec2b3993-890a-4b51-932d-f806351f2b57",
"consent_status": "ACCEPTED",
"consent_id": "3124912f-6624-2349-8379-246745fadf7b"
}
}
}
Note: In the example above,
BANK_STATEMENT_PERIODIChas"consent_status": "REQUESTED"— this means the user did not give consent for that template. OnlyBANK_STATEMENT_ONETIMEwas accepted.
Handle the response¶
onResult is called once with the final consent outcome:
result.success == true: consent completed successfully andaaSessionIdis available.result.timeout == true: the user did not complete consent in time.- Otherwise: treat it as a failure and read
result.error.
Notes¶
- Use your deployed AccountGator journey URL as
baseUrl. - Use a redirect URL you control. Avoid pages like Google that block iframe/WebView rendering.
- If needed, pass
allowedOriginsto restrict which web origins are allowed to send result messages.
Example app¶
A complete runnable example is available under example/.
Run it with: