Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 1.2 KB

File metadata and controls

18 lines (14 loc) · 1.2 KB

Auth Code sample - ASP.NET Core in .NET 5 MVC

This is a sample ASP.NET Core in .NET 5 MVC app that shows, as simply as possible, the steps needed to get an access token and refresh token with the OAuth 2 Authorization Code flow.

Most of the code that illustrates how to work with authorization is in AuthController.

Basic steps

  • Ensure you have a working ASP.NET Core in .NET 5 development environment on your machine
  • Fill in Secrets:ApiKey and Secrets:ApiSecret in appsettings.Development.json with your Getty API key and secret
  • Run the app
    • From Visual Studio or JetBrains Rider, load the solution and hit F5 or Ctrl-F5
    • From the CLI: dotnet run --project code-samples/dotnet/AuthCodeWebAppMVC/AuthCodeWebAppMVC/AuthCodeWebAppMVC.csproj
  • Go to http://localhost:5000
    • You can modify BaseUrl in Program.cs if you need a different port
  • Click the "Start auth code authentication" link
  • Log in with a username and password when prompted
  • Observe the tokens are returned and displayed in a view in the app