AngularJS 的 OAuth2 模块 angular-oauth2

码农软件 · 软件分类 · AngularJS 扩展 · 2019-03-17 09:28:38

软件介绍

angular-oauth2 是 AngularJS 的 OAuth2 认证模块,使用 ES6 编写。

使用方法:

1. 引入 js 库:

<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-cookie/dist/angular-cookie.min.js"></script>
<script src="bower_components/query-string/query-string.min.js"></script>
<script src="bower_components/angular-oauth2/dist/angular-oauth2.min.js"></script>

2. 配置 OAuth 和 OAuthToken

angular.module('myApp', ['angular-oauth2'])
  .config(['OAuthProvider', function(OAuthProvider) {
    OAuthProvider.configure({
      baseUrl: 'https://api.website.com',
      clientId: 'CLIENT_ID',
      clientSecret: 'CLIENT_SECRET',
    });
  }]);

3. 错误处理:

angular.module('myApp', ['angular-oauth2'])
  .run(['$rootScope', '$window', function($rootScope, $window) {
    $rootScope.$on('oauth:error', function(event, rejection) {
      // Ignore `invalid_grant` error - should be catched on `LoginController`.
      if ('invalid_grant' === rejection.data.error) {
        return;
      }

      // Redirect to `/login` with the `error_reason`.
      return $window.location.href = '/login?error_reason=' + rejection.data.error;
    });
  }]);

本文地址:https://codercto.com/soft/d/1529.html

Handbook of Data Structures and Applications

Handbook of Data Structures and Applications

Dinesh P. Mehta / Chapman and Hall/CRC / 2004-10-28 / USD 135.95

In the late sixties, Donald Knuth, winner of the 1974Turing Award, published his landmark book The Art of Computer Programming: Fundamental Algorithms. This book brought to- gether a body of kno......一起来看看 《Handbook of Data Structures and Applications》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具