title: MSAL.Net No account or login hint was passed to the AcquireTokenSilent call
body: <p>I have seen many same or similar questions, and tried all their answers if there was one, but none of those works for me.</p>
  
  <p>I'm using <a href="https://github.com/Azure-Samples/ms-identity-javascript-angular-spa-aspnetcore-webapi" rel="nofollow noreferrer">this example</a> from Microsoft's Github account as my project base.</p>
  
  <p>It works well for just signing in users.</p>
  
  <p>The project has 1 WebApi, 1 Angular App.</p>
  
  <p>Then I followed this <a href="https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/master/2-WebApp-graph-user/2-1-Call-MSGraph" rel="nofollow noreferrer">Microsoft example</a> to add code to call Graph API.
  Here is the controller code:</p>
  
  <pre><code>[Authorize]
  [Route("api/[controller]")]
  [ApiController]
  public class BillsController : ControllerBase
  {
      static readonly string[] scopeRequiredByApi = new string[] { "access_as_user" };
      readonly ITokenAcquisition tokenAcquisition;
      readonly WebOptions webOptions;
  
      public BillsController(ITokenAcquisition tokenAcquisition,
                            IOptions&lt;WebOptions&gt; webOptionValue)
      {
          this.tokenAcquisition = tokenAcquisition;
          this.webOptions = webOptionValue.Value;
      }
  
      [HttpGet]
      [AuthorizeForScopes(Scopes = new[] { Constants.ScopeUserRead, Constants.ScopeMailRead })]
      public async Task&lt;IActionResult&gt; Profile()
      {
          HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi);
  
          var subject = string.Empty;
          try
          {
              // Initialize the GraphServiceClient. 
              Graph::GraphServiceClient graphClient = GetGraphServiceClient(new[] { Constants.ScopeUserRead, Constants.ScopeMailRead });
  
              var me = await graphClient.Me.Request().GetAsync();
              // Get user photo
              var messages = await graphClient.Me.MailFolders.Inbox.Messages.Request().GetAsync();
              subject = messages.First().Subject;
              return Ok(subject);
          }
          catch (System.Exception ex)
          {
              throw ex;
          }
      }
  
      private Graph::GraphServiceClient GetGraphServiceClient(string[] scopes)
      {
          return GraphServiceClientFactory.GetAuthenticatedGraphClient(async () =&gt;
          {
              string result = await tokenAcquisition.GetAccessTokenForUserAsync(scopes);
              return result;
          }, webOptions.GraphApiUrl);
      }
  }
  </code></pre>
  
  <p>For Startup.cs</p>
  
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          // Setting configuration for protected web api
          services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
              .AddProtectedWebApi(Configuration);
  
          services.AddWebAppCallsProtectedWebApi(Configuration, new string[] { Constants.ScopeUserRead, Constants.ScopeMailRead })
              .AddInMemoryTokenCaches();
  
          services.AddOptions();
          services.AddGraphService(Configuration);
  
          // Creating policies that wraps the authorization requirements
          services.AddAuthorization();
  
          services.AddDbContext&lt;TodoContext&gt;(opt =&gt; opt.UseInMemoryDatabase("TodoList"));
  
          services.AddControllers();
  
          // Allowing CORS for all domains and methods for the purpose of sample
          services.AddCors(o =&gt; o.AddPolicy("default", builder =&gt;
          {
              builder.AllowAnyOrigin()
                     .AllowAnyMethod()
                     .AllowAnyHeader();
          }));
      }
  
      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          if (env.IsDevelopment())
          {
              // Since IdentityModel version 5.2.1 (or since Microsoft.AspNetCore.Authentication.JwtBearer version 2.2.0),
              // Personal Identifiable Information is not written to the logs by default, to be compliant with GDPR.
              // For debugging/development purposes, one can enable additional detail in exceptions by setting IdentityModelEventSource.ShowPII to true.
              // Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
              app.UseDeveloperExceptionPage();
          }
          else
          {
              // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
              app.UseHsts();
          }
  
          app.UseExceptionHandler("/error");
  
          app.UseCors("default");
          app.UseHttpsRedirection();
          app.UseCookiePolicy();
          app.UseRouting();
          app.UseAuthentication();
          app.UseAuthorization();
          app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapControllers();
          });
      }
  </code></pre>
  
  <p>On the Angular App, I added one button to call this Profile() controller action.</p>
  
  <p>todo-view.component.ts</p>
  
  <pre><code>  getEmails(): void {
      this.service.getEmails().subscribe({
        next: (emails: any) =&gt; {
          alert(emails);
        },
        error: (err: any) =&gt; {
          console.log("error happened~!");
          console.log(err);
        }
      });
    }
  </code></pre>
  
  <p>todo-view.component.html</p>
  
  <pre><code>&lt;button (click)="getEmails();"&gt;Get Emails&lt;/button&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/VpXkE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VpXkE.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p>I added the below code into my Startup.cs and removed the AddWebAppCallsProtectedWebApi.
      services.AddProtectedWebApiCallsProtectedWebApi(Configuration).AddInMemoryTokenCaches();</p>
  
  <p>Now it throws me a different error message:</p>
  
  <p><a href="https://i.stack.imgur.com/3obkO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3obkO.png" alt="enter image description here"></a></p>