title: Convert authorization code to access_token in ASP.NET Core MVC to call a .NET framework API
body: <p>I have an ASP.NET Core MVC application which calls a .NET framework API.</p>
  
  <p>The MVC application uses the hybrid flow and gets the <code>id_token</code> and authorization code using the following code in <code>Startup.cs</code>:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.Configure&lt;CookiePolicyOptions&gt;(options =&gt;
      {
          options.CheckConsentNeeded = context =&gt; true;
          options.MinimumSameSitePolicy = SameSiteMode.None;
      });
  
      services.AddAuthentication(options =&gt;
          {
              options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
              options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
              options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
          })
          .AddCookie()
          .AddOpenIdConnect(options =&gt;
          {
              options.Authority = Configuration["AzureAD:Instance"] + 
               "/" + Configuration["AzureAD:TenantId"];
              options.ClientId = Configuration["AzureAD:ClientId"];
              options.Secret = Configuration["AzureAD:Secret"];
              options.Callback = Configuration["AzureAD:Callback"];
              options.ResponseType = "code id_token";
              options.SaveTokens = true;
          });
  
      services.AddMvc(options =&gt;
          {
              var policy = new AuthorizationPolicyBuilder()
                  .RequireAuthenticatedUser()
                  .Build();
              options.Filters.Add(new AuthorizeFilter(policy));
          })
          .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
  }
  
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
      ...
      app.UseCookiePolicy();
      app.UseAuthentication();
      app.UseMvc(routes =&gt;
      {
          routes.MapRoute(
              name: "sign-in",
              template: "signin-oidc")};
  
  
          ...
  
  });
  </code></pre>
  
  <p>In the controller, when I check the <code>HttpContext</code>, I can get the <code>id_token</code> and authorization code. But I need to pass the <code>access_token</code> to the API.</p>
  
  <p>How do I get the <code>access_token</code> from the authorization code?</p>
  
  <p>Is MSAL/ADAL used for the above purpose? If so how can I get the <code>access_token</code> using MSAL?</p>
  
  <p>Could someone please point me to some example code?</p>