angular-digits

AngularJS module for Twitter Fabric Digits

Added by: Sam Deering

GitHub

Repository

ajwhite/angular-digits

Stats

Stars: 1

Watchers: 1

Forks: 1

Module Description

angular-digits

This is an angular wrapper for twitter fabric's digits sdk. It bridges the gap between Angular's digest cycle and the foreign SDK by applying the asynchronous events to the digest cycle. It also provides convenient models to provide insight to the responses from the API (if the workflow was closed by the user, popup was blocked, etc).

Example usage

angular.module('app', ['atticoos.digits'])

.config(function (DigitsProvider) {
  // configure the provider before the application's run phase
  DigitsProvider.setConsumerKey('XXX');
})

.run(function (Digits) {
  Digits.login().then(function (loginResponse) {
    // successfully logged in
  }).catch(function (error) {
    // a decorated error object describing the issue logging in
    if (error.wasPopupBlocked()) {
      // popup blocked
    } else if (error.wasWindowClosed()) {
      // user closed the window
    } else {
      // something else
    }
  });
});

Response Objects

This wrapper comes with some convenient models for better transparency of state and response information from the Digits SDK. It is suggested by the Digits SDK Docs that you securely verify the response data when logging in.

Login Response

Digits.login().then(function (loginResponse) { });

loginResponse.getOAuthHeaders()

Returns: Object

Returns the headers used to perform verification of the login response (X-Verify-Credentials-Authorization and X-Auth-Service-Provider)

{
  authorization: 'xx',
  url: 'https://xx'
}

Error Response

Digits.login().catch(function (loginError) { });

loginError.wasWindowClosed()

Returns: Boolean

Indicates if the workflow was aborted directly by the user closing the window before the process had completed

loginError.wasPopupBlocked()

Returns: Boolean

Indicates if the browser prevented the workflow by blocking the popup

loginError.type

The type attribute from the original response object

loginError.message

The message attribute from the original response object

Module stats last updated: 2015-04-19 15:05:09

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!