Reputation: 1
I started a blank Angular app and began following Auth0's setup guide, opting to use npm install
in lieu of using yarn or including the script from Auth0's CDN. I don't get past step 1 ("Setup your application's code" in the header) without getting the following errors when I run ng serve
:
ERROR in /Users/g/Documents/Projects/login/src/app/app.component.ts (2,29): Cannot find module './auth/auth.service'.
ERROR in /Users/g/Documents/Projects/login/src/app/app.component.ts (10,28): Cannot find name 'Authservice'.
Here is my app.component.ts code (the only code I modified from Angular's blank setup):
import { Component } from '@angular/core';
import { AuthService } from './auth/auth.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor(public auth: Authservice) {
auth.handleAuthentication();
}
}
What am I doing wrong here? There isn't a lot of opportunity for error in the first step of that guide, but I'm guessing part of the problem is that running npm install --save auth0-js doesn't put an "auth" folder in my project, and it appears that the second line of code in my app.component.ts file is trying to reference an "auth" folder.
Upvotes: 0
Views: 9580
Reputation: 447
You have to write your own service or you can download and use library like : https://github.com/cornflourblue/angular-7-registration-login-example/tree/master/src/app/_services
Upvotes: 0
Reputation: 1
Auth0 support linked me to this solution. I can't implement it because I can't change the callback URI for my project but I'm leaving it here for the record.
Upvotes: 0
Reputation: 629
@joevern
Seems like you are using a setup guide that is no longer valid. Here's an updated link to the Packages' documentation.
https://www.npmjs.com/package/auth0-js
To get started, All you need to do is npm install
the auth0-js
package, and then import it in your component like this.
import * as auth0 from "auth0-js";
On how to use the variable auth0, you can refer the documentation.
Upvotes: 1