Auth0 Home Blog Docs

Where should add the CDN script?

I am beginning to integrate Auth0 to my Angular 7 project, and I would like to know where should I insert the CDN script?

<script src=""></script>

Is it on the Index.html? On the header? Body?

Hi @leongrin! The best way to include auth0.js in your Angular project will be using the npm package. In your project’s root, run:

npm install auth0-js@latest --save

You will then be able to import auth0 in your Angular services like so:

import * as auth0 from 'auth0-js';
1 Like

Hi Kim. I installed auth0.js with npm, and I am importing auth0 successfully on my Angular service (import * as auth0 from ‘auth0-js’;).

But are you sure I can skip the “add script” step recommended by the guide?
See attached image.

I am asking this because I am still getting errors with authentications (see attached image), and when I add the recommended script tag to my index head or body, I get a new error.

BTW, it doesn’t seem to be a problem with the Allowed Web Origins config.

Hi @leongrin. We need to separate two different usages of SDKs in this scenario:

On the app side, the sample from the quickstart references the auth0-js package in the package.json file:

The code then uses import to reference the package installed:

In the screenshot you provided, you are showing Lock in the hosted login page. This is separate from the specifics of the angular application (or any other application that you might have), and its purpose is to authenticate the user. The particular error message displayed about not finding /user/ssodata is misleading, as this is expected on new tenants. I’ve reported this in this GH issue, hopefully the message will be improved soon.

Hi Nicolas,

Good to know that I should not worry about this user.ssodata error message. I thought this error might be related to another error, which is when I refresh the page with the user logged in, the app state is lost and the user is logged out. Do you know what could be causing this?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.