You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: resource-server/README.md
+36-8
Original file line number
Diff line number
Diff line change
@@ -21,22 +21,50 @@ A typical resource-server requires a frontend and a backend application, so you
21
21
22
22
## Running This Example
23
23
24
-
**backend:**
24
+
### Backend
25
25
26
-
Clone this repo and replace the okta configuration placeholders in the `appsettings.json` with your configuration values from the Okta Developer Console.
27
-
You can see all the available configuration options in the [okta-aspnet GitHub](https://github.com/okta/okta-aspnet/blob/master/README.md).
28
-
For step-by-step instructions, visit the Okta [ASP.NET Web API quickstart].
26
+
Run the example with your preferred tool and write down the port of your Web API application to configure Okta afterwards.
29
27
30
-
> **NOTE:**The above command starts the resource server on port 8000. You can browse to `http://localhost:8000/api/messages` to ensure it has started. If you get a 401 HTTP error, it indicates that the resource server is up. You will need to pass an access token to access the resource, which will be done by the front-end below.
28
+
> **NOTE:**This sample is using ASP.NET Core 2.2 which enforces HTTPS. This is a recommended practice for web applications. Check out [Enforce HTTPS in ASP.NET Core] for more details.
31
29
32
-
**front-end:**
30
+
#### Run the Web API application from Visual Studio
33
31
34
-
If you want to use one of our front-end samples, open a new terminal window and run the [front-end sample project of your choice](Prerequisites). Once the front-end sample is running, you can navigate to http://localhost:8080 in your browser and log in to the front-end application. Once logged in, you can navigate to the "Messages" page to see the interaction with the resource server.
32
+
If you run this project in Visual Studio it will start the resource server on ports 5000 for HTTP and 44314 for HTTPS. You can change this configuration in the `launchSettings.json`.
33
+
You can browse to `https://localhost:44314/api/messages` to ensure it has started. If you get a 401 HTTP error, it indicates that the resource server is up. You will need to pass an access token to access the resource, which will be done by the front-end below.
34
+
35
+
#### Run the Web API application from dotnet CLI
36
+
37
+
If you run this project via the dotnet CLI it will start the resource server on ports 5000 for HTTP and 5001 for HTTPS. You can change this configuration in the `launchSettings.json`.
38
+
39
+
Navigate to the folder where the project file is located and type the following:
40
+
41
+
```dotnet run```
42
+
43
+
You can browse to `https://localhost:5001/api/messages` to ensure it has started. If you get a 401 HTTP error, it indicates that the resource server is up. You will need to pass an access token to access the resource, which will be done by the front-end below.
44
+
45
+
#### Trust the local dev certificate if necessary
46
+
47
+
If you’ve never run an ASP.NET Core 2.x application before, you may notice a strange error page come up warning you that the site is potentially unsafe.
48
+
This is because ASP.NET Core creates an HTTPS development certificate for you as part of the first-run experience, but it still needs to be trusted. You can ignore the warning by clicking on Advanced and telling the browser that it’s okay to visit this site even though there is no certificate for it. Or you can trust the certificate to get rid of this warning, check out [Configuring HTTPS in ASP.NET Core across different platforms] for more details.
49
+
50
+
### Add your Okta configuration to the sample's appsettings
51
+
52
+
Replace the okta configuration placeholders in the `appsettings.json` with your configuration values from the [Okta Developer Console].
53
+
You can see all the available configuration options in the [okta-aspnet GitHub](https://github.com/okta/okta-aspnet/blob/master/docs/aspnetcore-webapi.md#configuration-reference).
54
+
For step-by-step instructions, visit the Okta [Protect your API endpoints guide]. The guide will walk you through adding Okta authentication to your API endpoints.
55
+
56
+
### Front-end
57
+
58
+
If you want to use one of our front-end samples, open a new terminal window and run the [front-end sample project of your choice](Prerequisites).
59
+
Make sure to update the resource server URI configuration to use your configured resource-server port (for example `https://localhost:5001`).
60
+
Once the front-end sample is running, you can navigate to `http://localhost:8080` in your browser and sign in to the front-end application. Once signed in, you can navigate to the "Messages" page to see the interaction with the resource server.
[ASP.NET Core Web API quickstart]: https://developer.okta.com/quickstart/#/widget/dotnet/aspnetcore
68
+
[Enforce HTTPS in ASP.NET Core]: https://docs.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?view=aspnetcore-2.2&tabs=visual-studio
69
+
[Configuring HTTPS in ASP.NET Core across different platforms]:https://devblogs.microsoft.com/aspnet/configuring-https-in-asp-net-core-across-different-platforms/
70
+
[Protect your API endpoints guide]: https://developer.okta.com/guides/protect-your-api/aspnetcore/before-you-begin/
0 commit comments