Skip to content

moureauf/oauth-mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OAuth Mock Server

This simple Flask app serves as a mock OAuth server implementing the Client Credentials flow. It generates a fake JWT access token for valid client credentials.

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/moureauf/oauth-mock.git
    cd oauth-mock
  2. Install dependencies:

    pip install -r requirements.txt

Configuration

Update the config.ini file with your OAuth configuration:

[OAuth]
client_id = yourClientId
client_secret = yourClientSecret
secret_key = yourSecretKey
user_id = yourUserId

[server]
port = 5000

Running the Server

Run the Flask app:

python oauth.py

The OAuth server will be accessible at http://127.0.0.1:5000.

Obtaining an Access Token

Make a POST request to http://127.0.0.1:5000/token with the following parameters:

  • client_id: Your client ID
  • client_secret: Your client secret
  • grant_type: 'client_credentials'

Example using curl:

curl -X POST -d "client_id=yourClientId&client_secret=yourClientSecret&grant_type=client_credentials" http://127.0.0.1:5000/token

The server will respond with a JSON containing the access token.

Error Handling

The server handles missing or invalid parameters gracefully and responds with appropriate error messages.

Note:

  • This is a simple mock server for educational purposes.
  • In a production environment, consider securing sensitive information better.
  • Do not use fake or weak secrets in real-world scenarios.

Feel free to customize the code and structure according to your needs.

Releases

No releases published

Packages

No packages published

Languages