lwa 0.0.2
lwa: ^0.0.2 copied to clipboard
LWA implements Login With Amazon over iOS (Swift) and Android (Kotlin).
Login With Amazon #
A Login With Amazon plugin for Flutter on iOS (Swift) and Android (Kotlin).
Supports basic authentication with the Amazon web API.
Authors: Firedance Multimedia LLC
License: MIT License
Getting Started #
The Official LWA Android Documentation
The Official LWA iOS Documentation
iOS Setup Instructions #
- Visit the Amazon Developer Console
- Register your iOS app including the bundle ID for your application
- In your
Info.plistset a key/value pair called apiKey (see example) - Add your CFBundleURLTypes key to the iOS Properties file. Include the bundle ID of your application, and update the URL Scheme to
amzn-your.bundle.id(see example) - Enter the apiKey provided by the Amazon Developer Console
Android Setup Instructions #
- Visit the Amazon Developer Console
- Register your Android bundle including your application identifier
- To retrieve your applications' md5 hash:
$ keytool -exportcert -alias your_alias -keystore /path/to/debug.keystore | \\
openssl dgst -md5 | \\
sed 's/[a-fA-F0-9][a-fA-F0-9]/&:/g; s/:$//'
- For the SHA256 fingerprint run:
$ keytool -v -list -keystore /path/to/debug.keystore
- In the
/andrid/app/src/maindirectory, add anassetsfolder and paste the api key into a file - Ensure the api key matches with no extra whitespace and name the file
api_key.txt(see example android folder)
Documentation #
The LWA Plugin #
Instantiate the LWA plugin inside of your application.
final _lwaPlugin = Lwa();
Start a stream to listen for LWA login and logout events.
_lwaPlugin.getLWAAuthState().listen((event) {
...code
});
Methods #
signIn(scopes)
await _lwaPlugin.signIn(scopes: ["profile"]);
Begins the authentication process with Login With Amazon. Accepts an optional array of scopes.
signOut()
await _lwaPlugin.signOut();
Logs the user out of Amazon, expiring their access token.
Events #
The signIn() and signOut() methods will broadcast events on the LWAAuthState stream. The event payloads are as follows:
loginSuccess
Map <response> - {
eventName: loginSuccess,
user_id: String containing the unique Amazon user ID,
name: String containing the Amazon users name,
email: String containing the Amazon users email,
accessToken: String containing the authentication token for the user
}
Fires when a user successfully completes the authentication process.
logoutSuccess
Map <response> - {
eventName: logoutSuccess
}
Fires when a user signs out from the Amazon service.
loginCancelled
Map <response> - {
eventName: loginCancelled
}
Fires when a user cancels the authentication process.
loginError
Map <response> - {
eventName: loginError
}
Fires when there is an error during the authentication process. Check the debug output for details.
logoutError
Map <response> - {
eventName: logoutError
}
Fires when there is an error during the authentication process. Check the debug output for details.