login_with_amazon 0.3.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 56

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 #

  • [x] Sign on with varying scopes
  • [x] Login With Amazon on Android
  • [x] Single Sign On on Android
  • [x] Get current Access Token on Android
  • [x] Retrieve full amazon response
  • [x] Simple setup with drop-in replacement of API key
  • [x] 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

0.3.0+1 #

  • modified the example app to make for easy early testing with dash replenishment or alexa devices
  • added text inputs to change dash device model or alexa product id

0.3.0 #

  • getAuthCode works correctly by accepting code challenge and method since it is device dependent

0.2.0 #

  • Added method to getAuthCode for dash replenishment devices

0.1.0 #

  • Added dartdoc comments

0.0.1 #

  • Android Only for the time being
  • Login With Amazon
  • Single Sign On on Android
  • Sign on with varying scopes
  • Retrieve full amazon response
  • Simple setup with drop-in replacement of API key

example/README.md

login_with_amazon_example #

Demonstrates how to use the login_with_amazon plugin.

Getting Started #

This project is a starting point for a Flutter application.

The LWA will not work without changing the API key per the Amazon Documents. In the android platform folder you need to change the app/src/main/assets/api_key.txt file by pasting your own key after generating it with amazon. Doing so requires finding your signing keys for the debug build. More information can be found in the amazon documents.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  login_with_amazon: ^0.3.0+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:login_with_amazon/login_with_amazon.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
12
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
56
Learn more about scoring.

We analyzed this package on Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test