title: Migrating IdentityServer4 from v3 to v4
body: <p>How to fix run time errors on MVC app and API, after migrating a working IdentityServer4 solution from v3 to v4?</p>
  <p>IdentityServer4 setup:</p>
  <pre><code>var builder = services.AddIdentityServer(    
     .AddInMemoryIdentityResources(Config.Ids)
     .AddInMemoryApiResources(Config.Apis)
     .AddInMemoryClients(Config.Clients)
     .AddTestUsers(TestUsers.Users);
  
  </code></pre>
  <pre><code>public static IEnumerable&lt;ApiResource&gt; Apis =&gt;
     new ApiResource[] 
     {
        new ApiResource(&quot;api1&quot;),
        new ApiResource(&quot;api2&quot;)
     };
  
  </code></pre>
  <p>MVC client config:</p>
  <pre><code>new Client
     {
        ClientName = &quot;MVC website&quot;,
        ClientId = &quot;mvcclient&quot;,
        ClientSecrets =
        {
           new Secret(&quot;secret2&quot;.Sha256())
        },
        AllowedGrantTypes = GrantTypes.Code,
        RequireConsent = false,
        RequirePkce = true,
  
        RedirectUris = { &quot;http://localhost:5002/signin-oidc&quot; },
        PostLogoutRedirectUris = { &quot;http://localhost:5002/signout-callback-oidc&quot; },
  
        AllowedScopes = {&quot;openid&quot;, &quot;profile&quot;, &quot;offline_access&quot;, &quot;api1&quot;, &quot;api2&quot; },
  
        AllowOfflineAccess = true,
     },
  </code></pre>
  <p>MVC app OpenId Connect setup:</p>
  <pre><code>.AddOpenIdConnect(&quot;oidc&quot;, options =&gt;
     {
        options.Authority = &quot;http://localhost:5000&quot;;
        options.RequireHttpsMetadata = false;
        options.ClientId = &quot;mvcclient&quot;;
        options.ClientSecret = &quot;secret2&quot;;
        options.ResponseType = &quot;code&quot;;
        options.SaveTokens = true;
        options.Scope.Add(&quot;api1&quot;);
        options.Scope.Add(&quot;api2&quot;);
        options.Scope.Add(&quot;offline_access&quot;);
        options.GetClaimsFromUserInfoEndpoint = true;
     });
  </code></pre>
  <p>Error after migration:</p>
  <pre><code>Sorry, there was an error : invalid_scope
  Invalid scope
  </code></pre>
  <p>API setup:</p>
  <pre><code>services.AddAuthentication(&quot;Bearer&quot;).AddJwtBearer(&quot;Bearer&quot;,
     options =&gt;
     {
        options.Authority = &quot;http://localhost:5000&quot;;
        options.Audience = &quot;api1&quot;;
        options.RequireHttpsMetadata = false;
     });
  </code></pre>
  <p>API error after migration:</p>
  <pre><code>401 Unauthorized
  </code></pre>