login_with_amazon 0.3.0+1 copy "login_with_amazon: ^0.3.0+1" to clipboard
login_with_amazon: ^0.3.0+1 copied to clipboard

A flutter plugin built to use Amazon's official Login With Amazon platform packages. With few other dependencies.

login_with_amazon #

A flutter plugin to use Amazon's native platform implementations of Login With Amazon. Like the Amazon platform packages it will only ask to authorize if already logged in on the device (single sign on). Alternatively it will ask to login.

Getting Started #

The API key must be changed on a per platform basis in accordance with the following instructions.

  • Android

    • in brief, after generating the API key on amazon, you must add it to your android project in the file app/src/main/assets/api_key.txt
    • you will likely need multiple keys, one for your debug application, and one for the live one as noted by amazon in the above documentation
  • iOS

  • Alexa or Dash Device authorization code generation

Methods #

import 'package:login_with_amazon/login_with_amazon.dart';

  • LoginWithAmazon
    • Future<Map> login(Map<String, dynamic> scopes)
    • Future<void> logout()
    • Future<String> getAccessToken(Map<String, dynamic> scopes)
    • Future<Map> getAuthCode(String codeChallenge, String codeChallengeMethod, Map<String, dynamic> scopes)

Scopes should match amazon scopes.

{
  'profile': null,
  'alexa:all': {
    'productID': 'SomeProductId',
    'productInstanceAttributes': {
      'deviceSerialNumber': 'serialNumberHere',
    },
  },
}
If a scope has no scopeData like the profile scope it should map to null.

{'profile': null}

Multiple scopes can be also be passed in all at once. Do Not Do This amazon doesn't always work as expected
{
  'profile': null,
  'alexa:all': {
    'productID': 'SomeProductId',
    'productInstanceAttributes': {
      'deviceSerialNumber': 'serialNumberHere',
    },
  },
  'dash:replenish': {
    'device_model': 'SomeDeviceModel',
    'serial': 'serialNumberHere',
    'is_test_device': true
  },
}

Login Response

The response from using the login method is a map of the AuthorizeResult. It is dependent on the scope.

{
    'accessToken': 'access token result',
    'user': {
        'userEmail': 'user email result',
        'userId': 'user id result',
        'userName': 'user name result',
        'userPostalCode': 'user postal code result',
        'user info': 'user info as a Map<String,String> result',
    },
}

Authorization Code Response

The response from using the login method is a map of the AuthorizeResult. It is dependent on the scope.

{
    'authorizationCode': 'access token result',
    'clientId': 'amazon client Id',
    'redirectUri': 'amazon redirect Uri'
}

Functionality #

  • ✅ Sign on with varying scopes
  • ✅ Login With Amazon on Android
  • ✅ Single Sign On on Android
  • ✅ Get current Access Token on Android
  • ✅ Retrieve full amazon response
  • ✅ Simple setup with drop-in replacement of API key
  • ✅ Get LWA Authorization Code for Dash replenishment device
  • ❌ Login With Amazon on iOS
  • ❌ Get LWA Authorization Code for Dash replenishment device on iOS
  • ❌ Logout on iOS
  • ❌ Get current Access Token on iOS
5
likes
40
pub points
0%
popularity

Publisher

verified publisherweplenish.com

A flutter plugin built to use Amazon's official Login With Amazon platform packages. With few other dependencies.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on login_with_amazon