【问题标题】:Auth0 with Angular2 "Supplied parameters do not match any signature of call target."带有 Angular2 的 Auth0 “提供的参数与调用目标的任何签名都不匹配。”
【发布时间】:2017-11-18 17:31:19
【问题描述】:

我目前正在尝试使用我的 Angular2 应用程序设置 Auth0。我正在使用 angular2-cli。我添加了一个名为 auth 的新服务。当我运行npm start 时,我收到错误src/app/auth.service.ts (21,5): Supplied parameters do not match any signature of call target.

这是我的 auth.service.ts

import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import 'rxjs/add/operator/filter';
import * as auth0 from 'auth0-js';

@Injectable()
export class AuthService {

  auth0 = new auth0.WebAuth({
    clientID: 'removed for privacy',
    domain: 'removed for privacy',
    responseType: 'token id_token',
    audience: 'removed for privacy',
    redirectUri: 'http://localhost:4200/callback',      
    scope: 'openid'
  });

  constructor(public router: Router) {}

  public login(): void {
    this.auth0.authorize();
  }

}

这是我的 package.json 中的依赖项

  "dependencies": {
    "@angular/cli": "^1.0.0-rc.0",
    "@angular/common": "^2.4.0",
    "@angular/compiler": "^2.4.0",
    "@angular/core": "^2.4.8",
    "@angular/forms": "^2.4.0",
    "@angular/http": "^2.4.0",
    "@angular/platform-browser": "^2.4.0",
    "@angular/platform-browser-dynamic": "^2.4.0",
    "@angular/router": "^3.4.0",
    "@angular2-material/button": "^2.0.0-alpha.5",
    "@angular2-material/card": "^2.0.0-alpha.5",
    "@angular2-material/checkbox": "^2.0.0-alpha.5",
    "@angular2-material/core": "^2.0.0-alpha.5",
    "@angular2-material/icon": "^2.0.0-alpha.5",
    "@angular2-material/input": "^2.0.0-alpha.5",
    "@angular2-material/list": "^2.0.0-alpha.5",
    "@angular2-material/toolbar": "^2.0.0-alpha.5",
    "core-js": "^2.4.1",
    "hammerjs": "^2.0.8",
    "pg": "^6.2.3",
    "pg-hstore": "^2.3.2",
    "rxjs": "^5.1.0",
    "sequelize": "^3.30.4",
    "sequelize-cli": "^2.7.0",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0-rc.0",
    "@angular/compiler-cli": "^2.4.0",
    "@types/hammerjs": "^2.0.34",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "gh-pages": "^0.12.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.4.2",
    "typescript": "~2.0.0",
    "video.js": "^5.19.2"
  }

我正在关注 Auth0 网站上的 Auth0 Angular2 + SDK 快速入门,但运气不佳。任何帮助将不胜感激。

【问题讨论】:

    标签: node.js angular npm auth0


    【解决方案1】:

    检查 auth0-js 库 here 的 API。

    authorize 函数接受一个对象参数。

    auth0.authorize({
      audience: 'https://mystore.com/api/v2',
      scope: 'read:order write:order',
      responseType: 'token',
      redirectUri: 'https://example.com/auth/callback'
    });
    

    login 函数中的以下函数抛出错误。

    this.auth0.authorize();
    

    【讨论】:

      猜你喜欢
      • 2017-08-24
      • 2017-05-08
      • 2017-11-14
      • 2016-12-07
      • 2018-01-08
      • 2016-11-27
      • 2016-06-09
      • 2023-03-15
      • 2017-04-28
      相关资源
      最近更新 更多