This project is an API server based on FastAPI (python), designed to facilitate the exchange of GitHub code for an access token. It provides a straightforward means for integrating GitHub authentication into your Python applications, allowing users to securely authenticate via GitHub OAuth.
- FastAPI Backend: Utilizes FastAPI, a modern, fast (high-performance), web framework for building APIs with Python.
- Secure Token Exchange: Exchange GitHub code for access tokens securely.
- RESTful API: Provides a clean and easy-to-use RESTful API for authentication purposes.
GET /github/callback?ci=<client_id>&cs=<client_secret>&ruri=<redirect_uri>&code=<code>
Key | Description |
---|---|
cs | client_secret |
ci | client_id |
ruri | redirect_uri |
code | code |
All the types of response that you will get if you call the api
{
"status": "200",
"msg": "Success",
"access_token": "token"
}
{
"status": "400",
"msg": "Missing code",
"key_missing":"code"
}
-
Clone the repository:
git clone https://github.com/aritrakrbasu/github-authentication-backend.git
-
Navigate into the project directory:
cd github-authentication-backend
-
Install dependencies:
pip install -r requirements.txt
-
Start the server:
uvicorn main:app --reload
-
Make requests to the API endpoints as needed.
Exchanges GitHub code for an access token.
Apologies for the oversight. Here's the corrected markdown file for the README:
markdown Copy code
This project is an API server based on FastAPI, designed to facilitate the exchange of GitHub code for an access token. It provides a straightforward means for integrating GitHub authentication into your Python applications, allowing users to securely authenticate via GitHub OAuth.
- FastAPI Backend: Utilizes FastAPI, a modern, fast (high-performance), web framework for building APIs with Python.
- OAuth Integration: Seamlessly integrate GitHub authentication into your applications.
- Secure Token Exchange: Exchange GitHub code for access tokens securely.
- RESTful API: Provides a clean and easy-to-use RESTful API for authentication purposes.
-
Clone the repository:
git clone https://github.com/your-username/github-authentication-backend.git
-
Navigate into the project directory:
cd github-authentication-backend
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.env
file in the root directory and add the following:GITHUB_CLIENT_ID=your-github-client-id GITHUB_CLIENT_SECRET=your-github-client-secret
Replace
your-github-client-id
andyour-github-client-secret
with your GitHub OAuth application's client ID and client secret respectively.
-
Start the server:
uvicorn main:app --reload
-
Make requests to the API endpoints as needed.
Exchanges GitHub code for an access token.
Contributions are welcome! Feel free to open issues or pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
Thanks to GitHub for providing OAuth authentication services. This project was inspired by the need for a simple and secure way to authenticate users via GitHub in various client side applications.