# Where should add the CDN script?

**URL:** <https://community.auth0.com/t/where-should-add-the-cdn-script/22302>\
**Category:** Get Help\
**Tags:** angular\
**Created:** [March 7, 2019, 7:22pm UTC](https://community.auth0.com/t/where-should-add-the-cdn-script/22302 "2019-03-07T19:22:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![leongrin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/leongrin/32/11624_2.png) [@leongrin](https://community.auth0.com/u/leongrin)\
**Post date:** [March 7, 2019, 7:22pm UTC](https://community.auth0.com/t/where-should-add-the-cdn-script/22302/1 "2019-03-07T19:22:25Z")

</div>

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="https://cdn.auth0.com/js/auth0/9.10/auth0.min.js"></script>

```

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

---

<div class="post-metadata">

**Author:** ![kim.maida](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kim.maida/32/17888_2.png) [@kim.maida](https://community.auth0.com/u/kim.maida)\
**Post date:** [March 7, 2019, 8:18pm UTC](https://community.auth0.com/t/where-should-add-the-cdn-script/22302/2 "2019-03-07T20:18:47Z")

</div>

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:

```auto
npm install auth0-js@latest --save

```

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

```auto
import * as auth0 from 'auth0-js';

```

---

<div class="post-metadata">

**Author:** ![leongrin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/leongrin/32/11624_2.png) [@leongrin](https://community.auth0.com/u/leongrin)\
**Post date:** [March 12, 2019, 1:11pm UTC](https://community.auth0.com/t/where-should-add-the-cdn-script/22302/3 "2019-03-12T13:11:51Z")

</div>

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? [Auth0 Angular SDK Quickstarts: Login](https://auth0.com/docs/quickstart/spa/angular2#loading-via-dependencies)  
See attached image.

 ![add-script](https://global.discourse-cdn.com/auth0/original/2X/4/4ba27cb9bcaf44f2dcd49ac56f2c5c4dc6ee8960.jpeg)

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.

 ![auth-error](https://global.discourse-cdn.com/auth0/original/2X/b/bbfe78635c43e2306936f75e44e19f43b4a1b6b1.jpeg)

---

<div class="post-metadata">

**Author:** ![leongrin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/leongrin/32/11624_2.png) [@leongrin](https://community.auth0.com/u/leongrin)\
**Post date:** [March 12, 2019, 1:14pm UTC](https://community.auth0.com/t/where-should-add-the-cdn-script/22302/4 "2019-03-12T13:14:46Z")

</div>

BTW, it doesn’t seem to be a problem with the Allowed Web Origins config.  
 ![allowed-web](https://global.discourse-cdn.com/auth0/original/2X/e/e9aaf1f27e84620e49ac76e540836847584e9880.jpeg)

---

<div class="post-metadata">

**Author:** ![nicolas\_sabena](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicolas_sabena/32/6064_2.png) [@nicolas\_sabena](https://community.auth0.com/u/nicolas_sabena)\
**Post date:** [March 12, 2019, 3:56pm UTC](https://community.auth0.com/t/where-should-add-the-cdn-script/22302/5 "2019-03-12T15:56:30Z")

</div>

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

- In your Angular app you are referencing Auth0.js, which will handle two basic tasks:
  - Redirect the user to your Auth0 domain’s `/authorize` endpoint to get a token ([auth0-angular-samples/auth.service.ts at cd6a635cc7b4ec8f3302da1582c3a18c97cd04d1 · auth0-samples/auth0-angular-samples · GitHub](https://github.com/auth0-samples/auth0-angular-samples/blob/cd6a635cc7b4ec8f3302da1582c3a18c97cd04d1/01-Login/src/app/auth/auth.service.ts#L34-L36))
  - Validate and process the response received from Auth0 once the user finishes the authorization flow ([auth0-angular-samples/auth.service.ts at cd6a635cc7b4ec8f3302da1582c3a18c97cd04d1 · auth0-samples/auth0-angular-samples · GitHub](https://github.com/auth0-samples/auth0-angular-samples/blob/cd6a635cc7b4ec8f3302da1582c3a18c97cd04d1/01-Login/src/app/auth/auth.service.ts#L38-L49)).

- In the Auth0 hosted login page (from the screenshot) you are using Lock. Lock is the UI widget that will get the credentials from the user and send them to Auth0 to continue the authorization process.

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

> <https://github.com/auth0-samples/auth0-angular-samples/blob/cd6a635cc7b4ec8f3302da1582c3a18c97cd04d1/01-Login/package.json#L24>

The code then uses `import` to reference the package installed: [auth0-angular-samples/auth.service.ts at cd6a635cc7b4ec8f3302da1582c3a18c97cd04d1 · auth0-samples/auth0-angular-samples · GitHub](https://github.com/auth0-samples/auth0-angular-samples/blob/cd6a635cc7b4ec8f3302da1582c3a18c97cd04d1/01-Login/src/app/auth/auth.service.ts#L4)

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](https://github.com/auth0/lock/issues/1604), hopefully the message will be improved soon.

---

<div class="post-metadata">

**Author:** ![leongrin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/leongrin/32/11624_2.png) [@leongrin](https://community.auth0.com/u/leongrin)\
**Post date:** [March 12, 2019, 5:22pm UTC](https://community.auth0.com/t/where-should-add-the-cdn-script/22302/6 "2019-03-12T17:22:20Z")

</div>

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?

 ![auth-state-lost-refresh](https://global.discourse-cdn.com/auth0/original/2X/4/45cac0aad1cb02124fbf8258ba5b473d60648df0.jpeg)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 27, 2019, 5:22pm UTC](https://community.auth0.com/t/where-should-add-the-cdn-script/22302/7 "2019-03-27T17:22:23Z")

</div>

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