silent_auth 0.0.4

  • Installing
  • Versions
  • 75


silent_auth is a package that enables seamless user experience for single page web applications using OAuth 2.0 - OpenID Connect with the implicit flow. More information can be found at Silent Authentication. In summary, this package

  • Performs login by redirecting user to an identity server's authorize endpoint
  • Performs logout by redirecting user to an identity server's end session endpoint
  • Periodically renews access/ID tokens in the background using iframe


This package is usually used together with an idle tracking library/package such as idle_tracker.

import 'package:silent_auth/silent_auth.dart';
import 'package:idle_tracker/idle_tracker.dart';

final silentAuth = new SilentAuth(
    baseIdentityUri: '',
    clientId: 'admin',
    scope: 'openid api',
    redirectUri: 'http://localhost:12345/index.html'
    silentRedirectUri: 'http://localhost:12345/silent_auth.html',
    onRenew: (auth) => requestHeaders['Authorization'] = 'Bearer ${auth.accessToken}');

// Request headers for making API calls.
final requestHeaders = {
  'Accept': 'application/json',
  'Content-Type': 'application/json; charset=UTF-8',
void logIn() {
  // Pre-login tasks may be done here.

void logOut() {
    // Pre-logout tasks may be done here.

void loadData() {
    // Make some API call using [requestHeaders].
void main() {
  // Initializes silent authentication.
  // If the access token doesn't exist or has expired, redirect user to the login page.
  if (!silentAuth.isAccessTokenValid) {
  // Set up an idle tracker to automatically log the user out after 30
  // minutes of inactivity.
  new IdleTracker(
      timeout: const Duration(minutes: 30),
      startsAsIdle: true,
      onIdle: logOut)

Features and bugs

Please file feature requests and bugs at the issue tracker.



  • Fixed a bug in which the token renewal is not properly scheduled the first time


  • Fixed a bug causing post_logout_redirect_uri not to be displayed in the logged-out page


  • Fixed a bug causing utils.callEndpoint to fail when compiled to JS


  • Initial version

1. Depend on it

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

  silent_auth: "^0.0.4"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:silent_auth/silent_auth.dart';
Version Uploaded Documentation Archive
0.0.4 Dec 22, 2017 Go to the documentation of silent_auth 0.0.4 Download silent_auth 0.0.4 archive
0.0.3 Dec 22, 2017 Go to the documentation of silent_auth 0.0.3 Download silent_auth 0.0.3 archive
0.0.2 Dec 4, 2017 Go to the documentation of silent_auth 0.0.2 Download silent_auth 0.0.2 archive
0.0.1 Dec 3, 2017 Go to the documentation of silent_auth 0.0.1 Download silent_auth 0.0.1 archive


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


Describes how popular the package is relative to other packages. [more]
50 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: web

Primary library: package:silent_auth/silent_auth.dart with components: html, js.


  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use silent_auth.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
Dev dependencies
test ^0.12.0