title: access_token same as id_token when trying to acquire access token with ADAL.js AuthenticationContext?
body: <p>I am authenticating my Single Page App (Angular4) with Azure AD, and using Adal.js for the same. On the login page, I click a button that redirects to Microsoft AAD and upon successful login it redirects back to application home page, and receives <code>id_token</code> and user info from JWT.</p>
  
  <p>I need the <code>access_token</code> for back-end API access, which I am trying to acquire through the the ADAL <code>AuthenticationContext</code>'s <code>getCachedToken()</code> method, and sending the clientId as parameter:</p>
  
  <pre><code>this.context.getCachedToken(this.configService.AdalConfig.clientId)
  </code></pre>
  
  <p>But this method returns the same token which is stored in session storage as <code>id_token (adal.idtoken)</code>. It basically creates a new item in session storage by with a concatenated key, which has same value as <code>id_token</code></p>
  
  <pre><code>adal.access_token.key + clientId = id_token
  </code></pre>
  
  <p>ex: <code>adal.access_token.key239f6fc7-64d2-3t04-8gfd-501efc25adkd = &lt;id-token-value&gt;</code>.</p>
  
  <p>I also tried to fetch <code>access_token</code> with <code>AuthenticationContext.acquireToken()</code> method, but it too gave the <code>id_token</code> back.</p>
  
  <p>Where am I going wrong?</p>
  
  <p><em>EDIT: posting the code.</em>
  I am calling the function <code>login()</code>, and after successful login, trying to get the access token in home page via <code>get accessToken()</code> property accessor in <code>adal.config.ts</code>.</p>
  
  <p><strong>config.service.ts</strong></p>
  
  <pre><code>import { Injectable } from '@angular/core';
  
  @Injectable()
  export class ConfigService {
    constructor() {}
    public get AdalConfig(): any {
      return {
        tenant: 'common',
        clientId: &lt;application-id&gt;,
        redirectUri: window.location.origin + '/',
        postLogoutRedirectUri: window.location.origin + '/'
      };
    }
  }
  </code></pre>
  
  <p><strong>adal.service.ts</strong></p>
  
  <pre><code>import { ConfigService } from './config.service';
  import { Injectable } from '@angular/core';
  import { adal } from 'adal-angular';
  let createAuthContextFn: adal.AuthenticationContextStatic = AuthenticationContext;
  
  @Injectable()
  export class AdalService {
    private context: adal.AuthenticationContext;
    constructor(private configService: ConfigService) {
      this.context = new createAuthContextFn(configService.AdalConfig);
    }
  
    login() {
      this.context.login();
    }
  
    logout() {
      this.context.logOut();
    }
  
    handleCallback() {
      this.context.handleWindowCallback();
    }
  
    public get userInfo() {
      return this.context.getCachedUser();
    }
  
    public get accessToken() {
      return this.context.getCachedToken(this.configService.AdalConfig.clientId);
      // return this.context.acquireToken(this.configService.AdalConfig.clientId, function(message, token, response) {
      //   console.log(message, token, response);
      // });
    }
  
    public get isAuthenticated() {
      return this.userInfo &amp;&amp; this.accessToken;
    }
  }
  </code></pre>