使用Angular2" Auth0提供的参数与呼叫目标的任何签名都不匹配。"

时间:2017-06-16 04:20:52

标签: node.js angular npm auth0

我目前正在尝试使用我的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快速入门并且没有运气。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分: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();