Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
dots
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-ciocirlan committed Aug 5, 2023
1 parent 1968bae commit 9b38f7a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions _posts/2023-07-29-oauth-authentication-scala-http4s.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ OAuth which stands for Open Authorization is an open standard framework that all

The OAuth standard is defined under [RFC 6749](https://www.ietf.org/rfc/rfc6749.txt), here we'll find an in-depth explanation of how the mechanism works.

## 2. Accessing the Github API through OAuth.
## 2. Accessing the Github API through OAuth

### 2.1. Setting Up.
### 2.1. Setting Up

In this section, we'll build an application that connects to GitHub using OAuth and request user information using the GitHub API.

Expand Down Expand Up @@ -69,7 +69,7 @@ val circeLibs = Seq(

We use Scala 3 in this tutorial, if you need to use Scala 2.13, you can do so with minimal code changes.

### 2.2. Registering our OAuth App on GitHub.
### 2.2. Registering our OAuth App on GitHub

Before we dive into Scala code, we need to register our application on github.com, Github will provide us with important credentials relevant for our app to function.

Expand Down Expand Up @@ -477,7 +477,7 @@ object OauthImpl {
}
```

### 2.5. The application routes.
### 2.5. The application routes

The next step is to define routes for our application. Let's create `AppRoutes.scala` in the following path, `oauth/src/main/scala/com/xonal/routes/AppRoutes.scala`.
In this section we will define two routes, the first will show our landing page which will be static HTML and the second will handle the call back from GitHub after the user authorizes our Oauth application.
Expand Down Expand Up @@ -584,7 +584,7 @@ Now let's create our index.html file in the following path, `oauth/src/main/scal

This HTML page prompts the user to click the link to receive his or her GitHub details. The link contains a scope and client_id as URL parameters. When the user clicks the link, he or she will be directed to GitHub and asked to sign in if not already. The user will then be prompted to authorize our OAuth app with the defined scope, after which GitHub will redirect the user to the above callback route.

### 2.6. The application server.
### 2.6. The application server

In this section, we'll work on the server. Create a `ServerUtil.scala` file in the following path, `oauth/src/main/scala/com/xonal/server/ServerUtil.scala` and add the following code.

Expand Down Expand Up @@ -615,7 +615,7 @@ object ServerUtil {
The `ServerUtil` object contains the `oauthServer()` function which takes `Config` and `HttpRoutes[F]` as parameters and returns a `Resource[F, Server]`.
We configure our server using `EmberServerBuilder` and pass it host and port values as `config.server.hostValue` and `config.server.portValue` respectfully. It also takes our `service` as a parameter through the `withHttpApp()` method.

### 2.7. The application's entry point.
### 2.7. The application's entry point

In this last section, we create our main function. Create a file called `OauthMain.scala` and save it in the following path, `oauth/src/main/scala/com/xonal/OauthMain.scala`. Add the following code.

Expand Down

0 comments on commit 9b38f7a

Please sign in to comment.