user8255292
user8255292

Reputation:

Getting error for auth0-js not found Angular2

I am trying to create login for my angular2 app using auth0.

I am following the link below:-

https://auth0.com/docs/quickstart/spa/angular2

I did the following steps:-

  1. Configure Callback URLs
  2. Install auth0.js
  3. npm install --save auth0-js
  4. retrieve auth0.js from Auth0's CDN.

Added below service:-

// src/app/auth/auth.service.ts

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

//const Auth0 = require('auth0-js');

//import * as auth0 from  './../../../node_modules/auth0-js/build/auth0.js';

@Injectable()
export class AuthService {

  auth0 = new Auth0.WebAuth({
    clientID: 'test',
    domain: 'www.test.com',
    responseType: 'token id_token',
    audience: 'personaluserinfo',
    redirectUri: 'http://localhost:3000/home',      
    scope: 'openid'
  });

  constructor(public router: Router) {}

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

}

But I am getting error as below:-

zone.js:2933 GET http://localhost:3000/auth0-js 404 (Not Found)

home:23 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/auth0-js

The answers on these pages below were not so useful to me:-

How configure SystemJS with Auth0?

Angular 2 + Auth0 (Could not find a declaration file for module 'auth0-js'. )

Any help would be appreciated.

Upvotes: 0

Views: 1087

Answers (1)

arcseldon
arcseldon

Reputation: 37125

As a first step, please (re-)review the instructions here for installing auth0.js when using Angular 2. This is a very popular quickstart, so should be accurate. If you continue to have issues, please leave comments below, and I shall install the quickstart myself to check everything.

Upvotes: 1

Related Questions