Wednesday, August 25, 2021

dev.to

 dev.to

Good  short no-nonsense useful articles


https://dev.to/palashmon/6-awesome-css-layout-generators-pbc

6 Awesome CSS Layout Generators


Web Development (3 Part Series)

1 Ultimate Cheatsheet Compilation

2 10 Awesome JavaScript Shorthands

3 6 Awesome CSS Layout Generators



https://dev.to/hb/10-fun-apis-to-use-for-your-next-project-2lco

10 Fun APIs to Use For Your Next Project



https://dev.to/hb/top-5-ides-code-editors-for-web-development-2mdo

Top 5 IDEs/Code Editors for Web Development



https://dev.to/hb/python-developer-roadmap-in-2021-2bmo

Python Developer Roadmap in 2021


https://dev.to/hb/30-machine-learning-ai-data-science-project-ideas-gf5

30 Machine Learning, AI, & Data Science Project Ideas


https://dev.to/hb/10-advanced-projects-to-build-in-2021-425o

10 Advanced Projects to Build in 2021




Friday, August 20, 2021

Resources

 


10 Resources for Learning LINQ

https://grantwinney.com/10-resources-for-learning-linq/


https://grantwinney.com/



https://docs.microsoft.com/en-us/dotnet/architecture/microservices/multi-container-microservice-net-applications/data-driven-crud-microservice

Creating a simple data-driven CRUD microservice



https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-5.0

ASP.NET Core Middleware


https://docs.microsoft.com/en-us/aspnet/core/fundamentals/startup?view=aspnetcore-5.0

App startup in ASP.NET Core


https://docs.microsoft.com/en-us/aspnet/core/fundamentals/?view=aspnetcore-5.0&tabs=windows

ASP.NET Core fundamentals


https://docs.microsoft.com/en-us/aspnet/core/blazor/?view=aspnetcore-5.0

Introduction to ASP.NET Core Blazor


https://techcommunity.microsoft.com/t5/microsoft-learn-blog/how-to-stay-motivated-during-your-learning-journey/ba-p/1469345

How to stay motivated during your learning journey


https://adrientorris.github.io/microsoft/microsoft-virtual-academy-mva-learning-paths.html
Microsoft Virtual Academy introduices the Learning Paths

https://cloud.google.com/training
google cloud training

Angular

https://netbasal.com/

Mt Techie Bar angular youtube tutorials

=========================================================================
Angular On Coursera

[Project]
Build ATM User Interface using Routing in Angular
https://www.coursera.org/projects/build-atm-user-interface-routing-angular

[Project] [2 hrs]
Routing and Navigation Concepts in Angular
https://www.coursera.org/projects/routing-and-navigation-concepts-in-angular


[Project] [2 hrs] 
Angular tooling: Generating code with schematics
https://www.coursera.org/projects/angular-schematics

[Project][3.5 hrs]
Learn Angular Routing by building a Cocktails Application
https://www.coursera.org/projects/angular-routing


[Project][2 hrs]
Test your Angular web application using Jasmine and Karma
https://www.coursera.org/projects/test-angular-web-application-jasmine-karma

[Course]
Front-End Web UI Frameworks and Tools: Bootstrap 4
https://www.coursera.org/learn/bootstrap-4?specialization=full-stack-mobile-app-development#syllabus

[Course]
Full Stack Web Development with Angular Specialization
https://www.coursera.org/specializations/full-stack-mobile-app-development#courses
=========================================================================
React : 

[Course]
Developing Cloud Apps with Node.js and React
https://www.coursera.org/learn/node-js?specialization=ibm-full-stack-cloud-developer#syllabus

[Course]
Full-Stack Web Development with React Specialization
https://www.coursera.org/specializations/full-stack-react

[Project] [2hrs]
Build your personal webpage using React and Github Pages
https://www.coursera.org/projects/build-your-personal-webpage
=========================================================================
Docker 

[Project][1.5 hrs]
TensorFlow Serving with Docker for Model Deployment
https://www.coursera.org/projects/tensorflow-serving-docker-model-deployment

[Project][3 hrs]
Introduction to Docker: Build Your Own Portfolio Site
https://www.coursera.org/projects/introduction-to-docker-build-portfolio-site

[Project][2 hrs]
Build local development environments using Docker containers
https://www.coursera.org/projects/build-local-development-environments-using-docker-containers


[Project][3 hrs]
Docker Essentials & Building a Containerized Web Application
https://www.coursera.org/projects/docker-container-essentials-web-app

[Project][1 hr 15 min]
Introduction to Docker : The Basics
https://www.coursera.org/projects/docker-fundamentals

[Project][2 hrs]
Docker for absolute beginners
https://www.coursera.org/projects/docker-for-absolute-beginners

[Course]
Building Containerized Applications on AWS
https://www.coursera.org/learn/containerized-apps-on-aws#syllabus
=========================================================================
Domain Driven Architecture

https://academy.lightbend.com/courses/course-v1:lightbend+LRA-DomainDrivenDesign+v1/about
Lightbend free course


https://blog.knoldus.com/introduction-to-domain-driven-design-ddd/
Introduction to Domain Driven Design (DDD)

https://github.com/ddd-by-examples/library

https://docs.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/ddd-oriented-microservice


Khalil Stemmler
Understanding Domain Entities [with Examples] - DDD w/ TypeScript
https://khalilstemmler.com/articles/typescript-domain-driven-design/entities/

https://khalilstemmler.com/articles/categories/domain-driven-design/
16 articles


https://airbrake.io/blog/software-design/domain-driven-design
Domain-Driven Design: What is it and how do you use it?


https://vaadin.com/learn/tutorials/ddd
Domain Driven Design Crash Course

Domain-driven Design Example
https://www.mirkosertic.de/blog/2013/04/domain-driven-design-example/
=========================================================================
Very important tutorial on sql server in docker

Restore a SQL Server database in a Linux Docker container
https://docs.microsoft.com/en-us/sql/linux/tutorial-restore-backup-in-sql-server-container?view=sql-server-ver15
=========================================================================
https://iq.opengenus.org/earn-money-from-github/

Wednesday, August 11, 2021

Entity Tracking in Entity Framework

Tracking is the feature of EF used to track changes in entities. 

If entities are changed, the changes are persisted to database during SaveChanges(), because those changes are tracked by EF.

Remember that Keyless entities are never tracked. 

Any query that returns an entity type is a tracking query. By default any query returning entity is called a tracking query and it is tracked. 

Even if a query anonymously returns an entity type, EF detects is and tracks the entity. 


To disable tracking on an entity returning query, use AsNoTracking()

    context.Blogs.AsNoTracking().ToList();

This behaviour can also be changed at context level: 

    context.ChangeTracker.QueryTrackingBehaviour = QueryTrackingBehaviour.NoTracking;


Identity Resolution: EF keeps track of tracked entities using the identity. It always maintains a single instance of tracked entities and returns the same instance when demanded, without hitting database. Thus when an entity is asked for, EF first checks whether entity with that identity already exists in context and returns the same if exists. This checking is done purely on the basis of identity property of the entity. 

This feature is called Identity resolution.

Non-tracking queries are not tracked, hence identity resolution is not done for them. Every time a no-tracking query is called, it results in a database hit. 


Now in EF5.0, we can have a non-tracking query with identity resolution. You need to use AsNoTrackingWithIdentityResolution() method for that. 

This creates a separate stand-alone tracker for this query and tracks it. After the query is enumerated fully, this stand-alone tracker goes out of scope and is garbage-collected. The context is not aware of this stand-alone tracking. 


What happens to tracking when the query contains a mix of tracked and keyless entities ?

From EF3.0 onwards, keyed entities in such mixed queries ARE tracked and keyless entities

are not tracked. 

Prior to EF3.0, the entire query results were untracked.

 https://www.softwareblogs.com/Home/Blog/how/DiffEF6andCore/entity-framework-6-entity-framework-core-difference-compare-examples


https://docs.microsoft.com/en-us/ef/efcore-and-ef6/


https://www.learnentityframeworkcore.com/

https://www.entityframeworktutorial.net/Types-of-Entities.aspx


https://chadgolden.com/blog/comparing-performance-of-ef6-to-ef-core-3

Thursday, August 5, 2021

Basic Client Authentication Using IdentityServer4 - The Client

 Let us now create the client. Out client will be a web api project which exposes weatherforecast api. 

1. Create a new asp .net core web api project: 





2. Main changes will be in startup.cs and a minor change is required in the controller file. 

We need to use JwtBearerDefaults structure in startup.cs. For that we need to install 

IdentityServer4.AccessTokenValidation package. Let us install this using nuget: 




3. In startup.cs, in the ConfigureServices method, add the following : 

        public void ConfigureServices(IServiceCollection services)

        {

            services.AddControllers();

            services.AddAuthentication(options => {

                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;

                options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;

            }).AddJwtBearer(op =>

            {

                op.Authority = "https://localhost:44368";

                op.Audience = "weatherapiresource";

            });


        }


4. In the Configure method, add  app.UseAuthentication();


        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }

This completes your modifications in startup.cs. The only remaining thing is to add [Authorize] attribute in controller. 


5. Go to controllers\WeatherForecastController and  add [Authorize] attribute before the [HttpGet] attribute of Get() method. You will need to reference Microsoft.AspNetCore.Authorization for it. 

         [Authorize]

        [HttpGet]

        public IEnumerable<WeatherForecast> Get()

        {

            var rng = new Random();

            return Enumerable.Range(1, 5).Select(index => new WeatherForecast

            {

                Date = DateTime.Now.AddDays(index),

                TemperatureC = rng.Next(-20, 55),

                Summary = Summaries[rng.Next(Summaries.Length)]

            })

            .ToArray();

        }


6. Build and Run the project. 

7. Notice that the project runs but gives an authorization error in the browser: 


The same error is given in postman too: 



8. This is because now the weatherforecast api requires a token to allow access to it. 

So let us generate a token using POSTMAN by calling /connect/token endpoint and then pass it to get request. 

To pass a token to get request in POSTMAN, open the "Authorization" tab of the request: 


Then open the "Type" drop down and select "Bearer Token" 


In the "Token" input box that appears on the right side, paste your token. 

And resend the GET request by pressing the "Send" button. 


9. Provided the token is not old and expired, you should now get the response of weatherforecast get api. 





Basic Client Authentication Using Identity Server 4 - The Server

 The aim of this tutorial is to use Identity Server 4 for client authentication. We will build two different VS projects, one will be server and other will be client. The server will host IdentityServer4 and do the task of authentication. The authentication will be based on client credentials, hence user , user id and password will not be required. 

Building the Identity Server

1. Create a new asp.net core web application project (the screen shots pertain to Visual Studio 2019). 




2. Once the project is created, add nuget packages IdentityServer4 and IdentityServer4.EntityFramework. 



3. Open startup.cs. 
At the end of  startup.cs add a new public class IS4Data. 
We will put the methods required by IS4 in this class. 

public class IS4Data
    {
        public static IEnumerable<ApiScope> GetApiScopes()
        {
            return new List<ApiScope>
             {
                 new ApiScope(name: "read",   displayName: "Read your data."),
                 new ApiScope(name: "write",  displayName: "Write your data."),
                 new ApiScope(name: "delete", displayName: "Delete your data."),
                 new ApiScope(name: "allow_weather_api", displayName: "Api Scope.")
             };
        }
        public static IEnumerable<ApiResource> GetApiResourses()
        {
            return new List<ApiResource>
            {
                 new ApiResource()
                        {
                        Name = "weatherapiresource",   //This is the name of the API
                        //Description = "This is the invoice",
                        Enabled = true,
                        DisplayName = "Weather API Resource",
                        Scopes = new List<string> { "allow_weather_api"},
                        }

        };
        }

        public static IEnumerable<Client> GetClients()
        {
            return new[]
            {
                new Client
                {
                    ClientId = "ABC Company Inc.",
                    AllowedGrantTypes = {GrantType.ClientCredentials },
                    ClientSecrets =  {
                        new Secret("ThisIsASecretString".Sha256())
                    }
                    ,
                    AllowedScopes = { "allow_weather_api" }
                }
            };
        }

    }


4. In the same file startup.cs, add the following code at the end of the ConfigureServices  method: 

            services.AddIdentityServer()
                .AddDeveloperSigningCredential()
                .AddInMemoryApiResources(IS4Data.GetApiResourses())
                .AddInMemoryApiScopes(IS4Data.GetApiScopes())
                .AddInMemoryClients(IS4Data.GetClients());

5. In the same file startup.cs, add a single statement in Configure method: 
            app.UseIdentityServer();

6. Run the project. This will take you to the browser on the weatherforcast api output. 

7. To test the server, use the .well-known/openid-configuration api. Supposing the project is running on localhost on the port 44368, you can browse to the URL  

https://localhost:44368/.well-known/openid-configuration


This will give an output like : 
{"issuer":"https://localhost:44368","jwks_uri":"https://localhost:44368/.well-known/openid-configuration/jwks","authorization_endpoint":"https://localhost:44368/connect/authorize","token_endpoint":"https://localhost:44368/connect/token","userinfo_endpoint":"https://localhost:44368/connect/userinfo","end_session_endpoint":"https://localhost:44368/connect/endsession","check_session_iframe":"https://localhost:44368/connect/checksession","revocation_endpoint":"https://localhost:44368/connect/revocation","introspection_endpoint":"https://localhost:44368/connect/introspect","device_authorization_endpoint":"https://localhost:44368/connect/deviceauthorization","frontchannel_logout_supported":true,"frontchannel_logout_session_supported":true,"backchannel_logout_supported":true,"backchannel_logout_session_supported":true,"scopes_supported":["read","write","delete","allow_weather_api","offline_access"],"claims_supported":[],"grant_types_supported":["authorization_code","client_credentials","refresh_token","implicit","urn:ietf:params:oauth:grant-type:device_code"],"response_types_supported":["code","token","id_token","id_token token","code id_token","code token","code id_token token"],"response_modes_supported":["form_post","query","fragment"],"token_endpoint_auth_methods_supported":["client_secret_basic","client_secret_post"],"id_token_signing_alg_values_supported":["RS256"],"subject_types_supported":["public"],"code_challenge_methods_supported":["plain","S256"],"request_parameter_supported":true}

If opened in POSTMAN with a GET request, the output will look like 
{
    "issuer""https://localhost:44368",
    "jwks_uri""https://localhost:44368/.well-known/openid-configuration/jwks",
    "authorization_endpoint""https://localhost:44368/connect/authorize",
    "token_endpoint""https://localhost:44368/connect/token",
    "userinfo_endpoint""https://localhost:44368/connect/userinfo",
    "end_session_endpoint""https://localhost:44368/connect/endsession",
    "check_session_iframe""https://localhost:44368/connect/checksession",
    "revocation_endpoint""https://localhost:44368/connect/revocation",
    "introspection_endpoint""https://localhost:44368/connect/introspect",
    "device_authorization_endpoint""https://localhost:44368/connect/deviceauthorization",
    "frontchannel_logout_supported"true,
    "frontchannel_logout_session_supported"true,
    "backchannel_logout_supported"true,
    "backchannel_logout_session_supported"true,
    "scopes_supported": [
        "read",
        "write",
        "delete",
        "allow_weather_api",
        "offline_access"
    ],
    "claims_supported": [],
    "grant_types_supported": [
        "authorization_code",
        "client_credentials",
        "refresh_token",
        "implicit",
        "urn:ietf:params:oauth:grant-type:device_code"
    ],
    "response_types_supported": [
        "code",
        "token",
        "id_token",
        "id_token token",
        "code id_token",
        "code token",
        "code id_token token"
    ],
    "response_modes_supported": [
        "form_post",
        "query",
        "fragment"
    ],
    "token_endpoint_auth_methods_supported": [
        "client_secret_basic",
        "client_secret_post"
    ],
    "id_token_signing_alg_values_supported": [
        "RS256"
    ],
    "subject_types_supported": [
        "public"
    ],
    "code_challenge_methods_supported": [
        "plain",
        "S256"
    ],
    "request_parameter_supported"true
}




You can also get token by calling /connect/token endpoint

The required credentials are grant_type, client_id and client_scecret






All the code chages are in startup.cs only and below is the complete startup.cs file. 


using IdentityServer4.Models;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Server
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to
        // add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddIdentityServer()
                .AddDeveloperSigningCredential()
                .AddInMemoryApiResources(IS4Data.GetApiResourses())
                .AddInMemoryApiScopes(IS4Data.GetApiScopes())
                .AddInMemoryClients(IS4Data.GetClients());
        }

        // This method gets called by the runtime. Use this method to
        // configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();
            app.UseIdentityServer();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
    }


    public class IS4Data
    {
        public static IEnumerable<ApiScope> GetApiScopes()
        {
            return new List<ApiScope>
             {
                 new ApiScope(name: "read",   displayName: "Read your data."),
                 new ApiScope(name: "write",  displayName: "Write your data."),
                 new ApiScope(name: "delete", displayName: "Delete your data."),
                 new ApiScope(name: "allow_weather_api", displayName: "Api Scope.")
             };
        }
        public static IEnumerable<ApiResource> GetApiResourses()
        {
            return new List<ApiResource>
            {


                new ApiResource()
                        {
                        Name = "weatherapiresource",   //This is the name of the API
                        //Description = "This is the invoice",
                        Enabled = true,
                        DisplayName = "Weather API Resource",
                        Scopes = new List<string> { "allow_weather_api"},
                        }


        };
        }

        public static IEnumerable<Client> GetClients()
        {
            return new[]
            {
                new Client
                {
                    ClientId = "ABC Company Inc.",
                    AllowedGrantTypes = {GrantType.ClientCredentials },
                    ClientSecrets =  {
                        new Secret("ThisIsASecretString".Sha256())
                    }
                    ,
                    AllowedScopes = { "allow_weather_api" }
                }
            };
        }

    }
}

Wednesday, August 4, 2021

 https://www.scottbrady91.com/Identity-Server/ASPNET-Core-Swagger-UI-Authorization-using-IdentityServer4

//https://stackoverflow.com/questions/63606288/invalid-token-the-audience-empty-is-invalid


https://www.youtube.com/watch?v=LVYEqNkf3aI

Create Identity Server 4 in .net core to secure Public microservices (Coding Friday)


https://stackoverflow.com/questions/44175115/how-to-use-refresh-token-in-identityserver-4


https://damienbod.com/2019/11/01/user-claims-in-asp-net-core-using-openid-connect-authentication/

https://damienbod.com/2016/11/18/extending-identity-in-identityserver4-to-manage-users-in-asp-net-core/


https://feras.blog/how-to-use-asp-net-identity-and-identityserver4-in-your-solution/

How To Use ASP.NET Identity And IdentityServer4 In Your Solution


https://codewithmukesh.com/blog/identityserver4-in-aspnet-core/

IdentityServer4 in ASP.NET Core – Ultimate Beginner’s Guide



https://stackoverflow.com/questions/59007998/getting-401-unauthorized-with-valid-access-token-using-identity-server-4-with-as


How to Use IS4 bearer auth in asp.net core web api project

 1. 

public void ConfigureServices(IServiceCollection services)
{
    services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
            .AddIdentityServerAuthentication(options =>
            {
                options.Authority = "https://localhost:44354";
                options.ApiName = "app.api.weather";
            });

    services.AddControllers();
}


To use IdentityServerAuthenticaltionDefaults, you need to install nuget package Microsoft.AspNet.Identity.Core



2. 

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    //..removed for brevity

    app.UseRouting();
    app.UseAuthentication();
    app.UseAuthorization();

    //..removed for brevity
}

3. 

[ApiController]
[Authorize]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
    //...removed for brevity
}










IdentityServer4-II- Basic Token generation using in-memory user credentials

 1. Create a class which generates dummy user and client information. For now you can keep this class in startup.cs itself. 

    public class IS4Data

    {

        public static IEnumerable<IdentityResource> GetIdentityResources() =>

  new List<IdentityResource>

  {

          new IdentityResources.OpenId(),

          new IdentityResources.Profile()

  };


        public static List<TestUser> GetUsers() =>

          new List<TestUser>

          {

      new TestUser

      {

          SubjectId = "a9ea0f25-b964-409f-bcce-c923266249b4",

          Username = "AAAA",

          Password = "AAAAAAAA",

          Claims = new List<Claim>

          {

              new Claim("FirstName", "AAAA"),

              new Claim("LastName", "Aaaa")

          }

      },

      new TestUser

      {

          SubjectId = "ec792526-8645-4677-8acb-6c0e73a0217c",

          Username = "BBBB",

          Password = "BBBBBBBB",

          Claims = new List<Claim>

          {

              new Claim("FirstName", "BBBB"),

              new Claim("LastName", "Bbbb")

          }

      }

          };



        public static IEnumerable<Client> GetClients() =>

    new List<Client>

    {

       new Client

       {

            ClientId = "ABC Company Inc.",

            ClientSecrets = new [] { new Secret("samplesecret".Sha512()) },

            AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,

            AllowedScopes = { IdentityServerConstants.StandardScopes.OpenId }

        }

    };


Notice that we are just generating users, clients and identity resources. 

2. Replace the is4 code in ConfigureServices with the following : 

        public void ConfigureServices(IServiceCollection services)

        {

            services.AddControllers();


            services.AddIdentityServer()

                .AddInMemoryClients(IS4Data.GetClients())

                .AddInMemoryIdentityResources(IS4Data.GetIdentityResources())

                //.AddInMemoryApiResources(new List<ApiResource>())

                //.AddInMemoryApiScopes(new List<ApiScope>())

                .AddTestUsers(IS4Data.GetUsers())

                .AddDeveloperSigningCredential();

        }


Notice how we are adding InMemoryClients, IdentityResources and TestUsers using our IS4Data class.


3. Now run the project. 

4. From POSTMAN, send a post request with 5 parameters: client_id, client_secrets, grant_type, username and password. 


5. You should get a token in response. 


{
    "access_token""eyJhbGciOiJSUzI1NiIsImtpZCI6IkU1NTVDOURCOEVDNEFDQjg2MTI3MEEyNjlGQT
A4MjcyIiwidHlwIjoiYXQrand0In0.eyJuYmYiOjE2MjgwNzM2MzEsImV4cCI6MTYyODA
                                3NzIzMSwiaXNzIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6NDQzMjciLCJjbGllbnRfaWQiOiJBQ
                                kMgQ29tcGFueSBJbmMuIiwic3ViIjoiYTllYTBmMjUtYjk2NC00MDlmLWJjY2UtYzkyMz
                                I2NjI0OWI0IiwiYXV0aF90aW1lIjoxNjI4MDczNjMxLCJpZHAiOiJsb2NhbCIsImp0aSI6IkU
                                yRDM5QTkxODBCRjM3MTE4NTdBOEY5OTVFRjE0Q0FBIiwiaWF0IjoxNjI4MDczNjMx
                                LCJzY29wZSI6WyJvcGVuaWQiXSwiYW1yIjpbInB3ZCJdfQ.FR6VyBTyEeHKL2jkln6txbGJ
                                2LSTbrGJXQvL4iMynjz6JqcOA6WYnOEFpCqSRQFxXSS12g5Y1mXqIylFmyYxfZ4FT8N9
                                Rpif23LmpS5jMBIQY_p1StQRhyDtU0nIHvIFQmQWBVAhZI8dieQmgzS6LUBWB_tXOejO
                                yfZA2OGgQgw_0MFUxjLI67FnOFEOxhO9DtLCo61_op9nROQ9AWQRnAek7GUCwb6jIboi
                                ODU9GTpHPGSHDcM9Gn_QmpAhc7yf3Ox1RyhFzwbewvBSixpUHoajrWo_NVdL9PBF5rT
                                8ey3lkG3UOK4O3zIfH40O6zPj_DXiXlJGcgsWYHtZN9Q1Fg",
    "expires_in"3600,
    "token_type""Bearer",
    "scope""openid"
}

The token is a JWT token. We can check using jwt.io





6. You can also call the userinfo endpoint. This should be a POST request with the above access-token
as a parameter. 




Below is the complete code of startup.cs: 

using IdentityServer4;
using IdentityServer4.Models;
using IdentityServer4.Test;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;

namespace WebApplication2
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services 
        //to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddIdentityServer()
                .AddInMemoryClients(IS4Data.GetClients())
                .AddInMemoryIdentityResources(IS4Data.GetIdentityResources())
                //.AddInMemoryApiResources(new List<ApiResource>())
                //.AddInMemoryApiScopes(new List<ApiScope>())
                .AddTestUsers(IS4Data.GetUsers())
                .AddDeveloperSigningCredential();
        }

        // This method gets called by the runtime. Use this method to configure 
        //the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.UseIdentityServer();
        }
    } //public class Startup


    public class IS4Data
    {
        public static IEnumerable<IdentityResource> GetIdentityResources() =>
  new List<IdentityResource>
  {
          new IdentityResources.OpenId(),
          new IdentityResources.Profile()
  };

        public static List<TestUser> GetUsers() =>
          new List<TestUser>
          {
      new TestUser
      {
          SubjectId = "a9ea0f25-b964-409f-bcce-c923266249b4",
          Username = "AAAA",
          Password = "AAAAAAAA",
          Claims = new List<Claim>
          {
              new Claim("FirstName", "AAAA"),
              new Claim("LastName", "Aaaa")
          }
      },
      new TestUser
      {
          SubjectId = "ec792526-8645-4677-8acb-6c0e73a0217c",
          Username = "BBBB",
          Password = "BBBBBBBB",
          Claims = new List<Claim>
          {
              new Claim("FirstName", "BBBB"),
              new Claim("LastName", "Bbbb")
          }
      }
          };


        public static IEnumerable<Client> GetClients() =>
    new List<Client>
    {
       new Client
       {
            ClientId = "ABC Company Inc.",
            ClientSecrets = new [] { new Secret("samplesecret".Sha512()) },
            AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,
            AllowedScopes = { IdentityServerConstants.StandardScopes.OpenId }
        }
    };

    } //IS4Data

//namespace



 using Microsoft.AspNetCore.Mvc; using System.Xml.Linq; using System.Xml.XPath; //<table class="common-table medium js-table js-stre...