How to set up the sample locally
The OpenIdConnect sample supports multilpe authentication providers. In these instruction, we will explore how to set up this sample with both Azure Active Directory and Google Identity Platform.
Determine your development environment and a few key variables
This sample is configured to run on port 44318 locally. In Visual Studio, the setting is carried out in
.\properties\launchSettings.json. When the application is run from command line, the URL is coded in
If the application is run from command line or terminal, environment variable ASPNETCORE_ENVIRONMENT should be set to DEVELOPMENT to enable user secret.
Configure the Authorization server
Configure with Azure Active Directory
- Set up a new Azure Active Directory (AAD) in your Azure Subscription.
- Open the newly created AAD in Azure web portal.
- Navigate to the Applications tab.
- Add a new Application to the AAD. Set the "Sign-on URL" to sample application's URL.
- Naigate to the Application, and click the Configure tab.
- Find and save the "Client Id".
- Add a new key in the "Keys" section. Save value of the key, which is the "Client Secret".
- Click the "View Endpoints" on the drawer, a dialog will shows six endpoint URLs. Copy the "OAuth 2.0 Authorization Endpoint" to a text editor and remove the "/oauth2/authorize" from the string. The remaining part is the authority URL. It looks like
Configure with Google Identity Platform
- Create a new project through Google APIs.
- In the sidebar choose "Credentials".
- Navigate to "OAuth consent screen" tab, fill in the project name and save.
- Navigate to "Credentials" tab. Click "Create credentials". Choose "OAuth client ID".
- Select "Web application" as the application type. Fill in the "Authorized redirect URIs" with
- Save the "Client ID" and "Client Secret" shown in the dialog.
- The "Authority URL" for Google Authentication is
Configure the sample application
- Restore the application.
- Set user secrets:
dotnet user-secrets set oidc:clientid <Client Id> dotnet user-secrets set oidc:clientsecret <Client Secret> dotnet user-secrets set oidc:authority <Authority URL>