Skip to content

authgear/authgear-example-dotnet

Repository files navigation

Authentication for ASP.NET apps with Authgear and OpenID Connect

This repo provides a basic demo web application, created using ASP.NET, and demonstrates how to add authentication features with Authgear by implementing an OpenID Connect flow, then retrieving OAuth tokens, in order to call APIs.

What is Authgear?

Authgear acts as an IAM provider that is a gatekeeper to the resources you provide to customers as web and mobile applications, APIs, etc. The gatekeeper initiates authorization as outlined in OAuth 2.0. The addition of the OpenID Connect layer adds authentication to secure your users’ digital identities and your product.

How to run the project

Prerequisites

Before you get started, you will need the following:

Start by cloning the project into your local machine:

git clone https://github.com/authgear/authgear-example-dotnet.git

Make the project directory your current working directory:

cd authgear-example-dotnet

Update the following configuration variables in the appsettings.json file with your Authgear app settings values from Authgear OIDC Client application such as IssuerClientIdClientSecret, and Authgear endpoint:

{
    "OpenIDConnect": {
        "ClientId": "{your-client-id}",
        "ClientSecret": "{your-client-secret}",
        "Issuer": "{your-authgear-app-endpoint}",
        "Scope": "openid offline_access",
        "PostLogoutRedirectUri": "http://localhost:5002",
        "TokenEndpoint": "{your-authgear-app-endpoint}/oauth2/token"
    },
    "Urls": "http://localhost:5002",
    "Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft": "Warning",
            "Microsoft.Hosting.Lifetime": "Information"
        }
    }
}

Execute the following command to run the ASP.NET Core web application:

dotnet build
dotnet run

You can now visit http://localhost:5002 to access the application. When you click on the "View Protected Data" button, ASP.NET Core takes you to the Authgear’s Login page.

About

Authentication for ASP.NET apps with Authgear and OpenID Connect

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published