# Angular access\_token appending to URL and 404

**URL:** <https://community.auth0.com/t/angular-access-token-appending-to-url-and-404/18657>\
**Category:** Get Help\
**Tags:** auth0-lock, angular4, angular, auth0, lock\
**Created:** [December 3, 2018, 8:47pm UTC](https://community.auth0.com/t/angular-access-token-appending-to-url-and-404/18657 "2018-12-03T20:47:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sstone2423](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sstone2423](https://community.auth0.com/u/sstone2423)\
**Post date:** [December 3, 2018, 8:47pm UTC](https://community.auth0.com/t/angular-access-token-appending-to-url-and-404/18657/1 "2018-12-03T20:47:42Z")

</div>

Hi, I’m attemping to implement auth0-lock into my Angular 4 web application am running into some access\_token issues. When I was only using the Angular development server on :4200, I was able to authenticate and everything ran smoothly. After building the app for production and running it on my node.JS web server, it is no longer authenticating correctly.

The lock appears on auth.login() and it appears as if authentication is successful, but the application then redirects to [http://localhost:8888/#/access\_token](http://localhost:8888/#/access_token)

My current settings in my authentication.service.ts is:

````import
import { Router } from '@angular/router';
import { tokenNotExpired } from 'angular2-jwt';
import { Auth0Lock } from 'auth0-lock';
(window as any).global = window;

@Injectable()
export class AuthenticationService {
  // https://site.auth0.com/
  auth0Options = {
      theme: {
          primaryColor: '#DFA612'
      },
      auth: {
        redirectUrl: 'http://localhost:8888/',
        responseType: 'token id_token',
        audience: 'https://dutchesscap.auth0.com/userinfo',
        params: {
          scope: 'openid profile'
        }
      },
      autoclose: true,
      oidcConformant: true,
  };
    
  lock = new Auth0Lock(
      'AbCdEf...',
      'site.auth0.com',
      this.auth0Options
  );

  userProfile: Object;

  constructor(private router: Router) {
    this.lock.on('authenticated', (authResult: any) => {
        // Set userProfile attribute of already saved profile
        this.userProfile = JSON.parse(localStorage.getItem('profile'));

        // Add callback for lock `authenticated` event
        this.lock.on("authenticated", (authResult) => {

            //https://github.com/auth0/auth0.js/issues/241
            
            localStorage.setItem('token', authResult.idToken);

            var accessToken: string = authResult.accessToken;
            localStorage.setItem('access_token', accessToken);

            // Fetch profile information
            //Use getUserInfo as getProfile is deprecated. Also need to pass in accessToken, not idToken.
            this.lock.getUserInfo(accessToken, (error, profile) => {
                if (error) {
                    // Handle error
                    alert(error);
                    return;
                }

                localStorage.setItem('profile', JSON.stringify(profile));
                this.userProfile = profile;
            });

            // Redirect if there is a saved url to do so.
            var redirectUrl: string = localStorage.getItem('redirect_url');
            if (redirectUrl != undefined) {
                this.router.navigate([redirectUrl]);
                localStorage.removeItem('redirect_url');
            }
        });

    });
  }

  // When called, produce the lock modal that allows authentication
  login() {
    this.lock.show();
  }

  // Remove the localStorage tokens and navigate to the survey page
  logout() {
    // Remove token from localStorage
    localStorage.removeItem('id_token');
    localStorage.removeItem('access_token');
    localStorage.removeItem('profile');

    this.router.navigate(['survey']);
  }

  // Checks if the token has expired / if it exists
  isAuthenticated() {
    return tokenNotExpired('id_token');
  }

}```
````

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [December 31, 2018, 10:50pm UTC](https://community.auth0.com/t/angular-access-token-appending-to-url-and-404/18657/2 "2018-12-31T22:50:56Z")

</div>

Hi there @sstone2423, when you get a chance can you snag us a HAR file and the tenant name from your production app when reproducing the error and DM it over to me? I would like to take a deeper look at what may occurring. Thanks in advance!

> **[Generate and Analyze HAR Files](https://auth0.com/docs/troubleshoot/troubleshooting-tools/generate-and-analyze-har-files)**
>
> Learn how to troubleshoot with HAR files and steps to generate a HAR file.

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [June 5, 2019, 5:05pm UTC](https://community.auth0.com/t/angular-access-token-appending-to-url-and-404/18657/4 "2019-06-05T17:05:26Z")

</div>


