docfix/Add OAuth 2.0 Client Credentials Flow to a Glossary

This commit is contained in:
Marko Milić 2025-03-26 09:41:48 +01:00
parent 145c9b5495
commit 44b5932f34
2 changed files with 67 additions and 4 deletions

View File

@ -0,0 +1,65 @@
# OAuth 2.0 Client Credentials Flow Manual
## Overview
OAuth 2.0 Client Credentials Flow is used when a client application (such as a backend service) needs to authenticate and request access to resources without user interaction. This flow is typically used for machine-to-machine (M2M) authentication.
## Prerequisites
Before making requests, ensure you have:
- A valid **client_id** and **client_secret**.
- The authorization server running on **localhost:7070**.
- The required endpoint available: `/realms/master/protocol/openid-connect/token`.
## 1. Requesting an Access Token
To obtain an access token, send a **POST** request to the token endpoint with the following details.
### **Request**
```
POST /realms/master/protocol/openid-connect/token HTTP/1.1
Host: localhost:7070
Content-Type: application/x-www-form-urlencoded
Authorization: Basic Og==
Content-Length: 104
client_id=open-bank-project&client_secret=WWJ04UzMhWmLEqW2KIgBHwD4UNEotzXz&grant_type=client_credentials
```
### **Explanation of Parameters**
| Parameter | Description |
|------------------|-------------|
| `client_id` | The unique identifier for your client application. |
| `client_secret` | The secret key assigned to your client. |
| `grant_type` | Must be set to `client_credentials` to indicate this authentication flow. |
### **Example cURL Command**
```sh
curl -X POST "http://localhost:7070/realms/master/protocol/openid-connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "open-bank-project:WWJ04UzMhWmLEqW2KIgBHwD4UNEotzXz" \
-d "grant_type=client_credentials"
```
## 2. Expected Response
A successful request will return a JSON response containing the access token:
```json
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600
}
```
### **Response Fields**
| Field | Description |
|----------------|-------------|
| `access_token` | The token required to authenticate API requests. |
| `token_type` | Usually `Bearer`, meaning it should be included in the Authorization header. |
| `expires_in` | The token expiration time in seconds. |
## 3. Using the Access Token
Once you obtain the access token, include it in the `Authorization` header of your subsequent API requests:
### **Example API Request with Token**
```sh
curl -X GET "http://localhost:7070/protected/resource" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
```

View File

@ -3514,10 +3514,8 @@ object Glossary extends MdcLoggable {
}
private def getListOfFiles():List[File] = {
val d = new File("src/main/docs/glossary").exists() match {
case true => new File("src/main/docs/glossary")
case false => new File("obp-api/src/main/docs/glossary")
}
val currentDir = new File(".").getCanonicalPath
val d = new File(currentDir + "/obp-api/src/main/docs/glossary")
if (d.exists && d.isDirectory) {
d.listFiles.filter(_.isFile).filter(_.getName.endsWith(".md")).toList
} else {