当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript OAuthService.loadDiscoveryDocument方法代码示例

本文整理汇总了TypeScript中angular-oauth2-oidc.OAuthService.loadDiscoveryDocument方法的典型用法代码示例。如果您正苦于以下问题:TypeScript OAuthService.loadDiscoveryDocument方法的具体用法?TypeScript OAuthService.loadDiscoveryDocument怎么用?TypeScript OAuthService.loadDiscoveryDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular-oauth2-oidc.OAuthService的用法示例。


在下文中一共展示了OAuthService.loadDiscoveryDocument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

    constructor(private oauthService: OAuthService) {
        // URL of the SPA to redirect the user to after login
        this.oauthService.redirectUri = window.location.origin/* + '/index.html'*/;

        // The SPA's id. The SPA is registerd with this id at the auth-server
        this.oauthService.clientId = 'spa-client';

        // set the scope for the permissions the client should request
        // The first three are defined by OIDC. The 4th is a usecase-specific one
        this.oauthService.scope = 'openid profile email';

        // set to true, to receive also an id_token via OpenId Connect (OIDC) in addition to the
        // OAuth2-based access_token
        this.oauthService.oidc = true;

        // Use setStorage to use sessionStorage or another implementation of the TS-type Storage
        // instead of localStorage
        this.oauthService.setStorage(sessionStorage);

        this.oauthService.issuer = 'https://his-auth.azurewebsites.net';

        // Set a dummy secret
        // Please note that the auth-server used here demand the client to transmit a client secret, although
        // the standard explicitly cites that the password flow can also be used without it. Using a client secret
        // does not make sense for a SPA that runs in the browser. That's why the property is called dummyClientSecret
        // Using such a dummy secreat is as safe as using no secret.
        this.oauthService.dummyClientSecret = 'geheim';

        this.oauthService.options = {
            _service: oauthService,
            onTokenReceived(params: any) {
                let promise: Promise<any> = this._service.loadUserProfile();
                promise.catch(function(err){console.error(err); });
            }
        };

        // Load Discovery Document and then try to login the user
        this.oauthService.loadDiscoveryDocument().then(() => {

            // This method just tries to parse the token(s) within the url when
            // the auth-server redirects the user back to the web-app
            // It dosn't send the user the the login page
            this.oauthService.tryLogin(this.oauthService.options);
        });
    }
开发者ID:Fanuer,项目名称:HIS,代码行数:45,代码来源:app.component.ts

示例2: configureAuth

  private configureAuth() {
    
    //
    // This method demonstrated the old API; see configureWithNewConfigApi for new one
    //

    // URL of the SPA to redirect the user to after login
    this.oauthService.redirectUri = window.location.origin + "/index.html";

    // URL of the SPA to redirect the user after silent refresh
    this.oauthService.silentRefreshRedirectUri = window.location.origin + "/silent-refresh.html";

    // The SPA's id. The SPA is registerd with this id at the auth-server
    this.oauthService.clientId = "spa-demo";

    // set the scope for the permissions the client should request
    // The first three are defined by OIDC. The 4th is a usecase-specific one
    this.oauthService.scope = "openid profile email voucher";

    // Url of the Identity Provider
    this.oauthService.issuer = 'https://steyer-identity-server.azurewebsites.net/identity';

    this.oauthService.tokenValidationHandler = new JwksValidationHandler();

    this.oauthService.events.subscribe(e => {
      console.debug('oauth/oidc event', e);
    });

    // Load Discovery Document and then try to login the user
    this.oauthService.loadDiscoveryDocument().then((doc) => {
      this.oauthService.tryLogin();
    });

    this
      .oauthService
      .events
      .filter(e => e.type == 'token_expires')
      .subscribe(e => {
        console.debug('received token_expires event', e);
        this.oauthService.silentRefresh();
      });
  }
开发者ID:bokzor,项目名称:angular-oauth2-oidc,代码行数:42,代码来源:app.component.ts


注:本文中的angular-oauth2-oidc.OAuthService.loadDiscoveryDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。