title: Asp.net core API authenticate with AzureAD Token
body: <p>I have a xamarin mobile app that users Azure ad to authenticate it's users.</p>
  <p>I would like to use the the token that is stored on the app to access data on an api. I have this working on an old api but I have created an asp.net core api and i would like to use the same token as i slowly migrate the data access from one api to the other.</p>
  <p>I have set up access in the asp.net core startup class as follows</p>
  <pre><code>            services.AddAuthentication(sharedoptions =&gt;
          {
          sharedoptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
          sharedoptions.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
                 })
           .AddJwtBearer(options =&gt;
              {
          options.Authority = &quot;https://login.microsoftonline.com/{ad name}.onmicrosoft.com&quot;;
          options.Audience = &quot;api://{app service guid}&quot;;
  
          options.TokenValidationParameters = new `enter code here`Microsoft.IdentityModel.Tokens.TokenValidationParameters
          {
              ValidateIssuer = true,
              ValidateAudience = true,
              ValidAudiences = new List&lt;String&gt; { &quot;{app service guid}&quot; },
              ValidIssuers = new List&lt;string&gt; { &quot;[https://login.microsoftonline.com/{Azure AD guid}/v2.0/token&quot;}
          };
      });
  </code></pre>
  <p>I test with post man and get unauthorised status on the asp.net core api, but an OK (authorised) status on the old api so i know the token is working.</p>
  <p>Does my set up appear to be correct or am i missing some configuration?</p>