semvec/pypi-packages huggingface dataset:
wt-authlib 0.1.6
Librairie d'authentification pour les apis WT
Requires Python: >=3.10

# README.md
# wt-authlib

Librairie d'authentification pour l'api wt_user. 
Cette librairie permet de sécuriser un projet FastAPI. Seules les personnes avec un compte WT pourront accéder l'API protégée.
Cette librairie se connecte à la base de donnée associée à wt_user pour récupérer les settings, les endpoints etc

## Fonctionnalités
- Permet de s'identifier à WT et récupérer un Bearer
- Décodage et validation des tokens Bearer pour les endpoints ou routers protégés
- Intégration facile avec FastAPI via `Depends`

## Installation
```bash
uv pip install wt_authlib
```

## Initialisation

Une fois installée, il est essentiel d'initialiser UserApi dans un lifespan FastAPI

```python
from contextlib import asynccontextmanager
from wt_authlib.user_api_client import UserApiClient

@asynccontextmanager
async def lifespan(_: FastAPI):
	UserApiClient.init(
		host="url de la base de données de wt_user",
		port="port la base de données de wt_user",
		username="username admin de la base de données de wt_user",
		password="passwaord admin de la base de données de wt_user",
	)
	yield

app = FastAPI(lifespan=lifespan)

```

## Sécurisation
il faut ajouter la méthode validate_user comme dépendance (Depends) aux endpoints ou routeur

### exemple ajout router

```python

from fastapi import APIRouter, Depends
from wt_authlib.fastapi_depends import validate_user

routeur = APIRouter()
routeur.include_router(
    document.router,
	dependencies=[Depends(validate_user)]
)
```

### exemple ajout endpoint
```python

from wt_authlib import validate_user

app = FastAPI()

@app.get("/private", dependencies=[Depends(validate_user)])
async def private_route():
    return {"message": "Bienvenue, utilisateur authentifié"}
```


## Login 
Une fois l'api sécurisé, il est est nécessaire de se loguer pour recevoir un Bearer token depuis wt_user.
Utilisez la methode UserApiClient.login() avec les credentials pour recevoir un token.


### Exemple avec un endpoint Fastapi
```python

from wt_authlib.user_api_client import UserApiClient
from wt_authlib.errors import UserApiException

@router.post("/login")
async def login(username: str, password: str):
    try:
        return await UserApiClient.login(username, password)
    except UserApiException as e:
        raise HTTPException(status_code=e.status_code, detail=e.message)

```
gpycraft 1.0.3
A Python package for manipulating google sheets directly on any coding platform and perform CRUD process easily. Sheets can be stored and retrieved in firebase storage

<link href='https://fonts.googleapis.com/css?family=MedievalSharp' rel='stylesheet'>

<h1 align="center" style="color: red; font-family: 'MedievalSharp'; font-size: 22px;">GPYCRAFT</h1>




<p align="center">
    <img src="https://raw.githubusercontent.com/Fru404/Web/main/1497441839.svg" alt="SVG" style="width: 200px; height: 200px; display: block; margin: 0 auto;">
</p>


This python module makes it possible to manipulate google sheets or any sheets stored in firebase storage. It allows for manipulation and display sheet data in a convenient way for analysis. It supports creation of API to google sheet

Before Starting it is neccessary to have credentials.json file found in Google cloud platform and make sure the google sheet link is shareable




# Read data from Google Sheets
data = db.read_sheet(key='column_name', number_of_rows=5, start_index=1, end_index=10)
key: The column name to filter data by.
number_of_rows: The number of rows to retrieve.
start_index and end_index: The range of rows to retrieve.
Converting Data to Pandas DataFrame
in_pd Method
python
Copy code
# Convert data to Pandas DataFrame
df = db.in_pd()
Converting Data to JSON
in_json Method
python
Copy code
# Convert data to JSON
json_data = db.in_json(target_key='column_name', num_rows=5, start_index=1, end_index=10)
target_key: The specific key to include in the JSON output.
num_rows: The number of rows to include in the JSON output.
start_index and end_index: The range of rows to include in the JSON output.
FireStoreUpload Class
Initialization
python
Copy code
from googlepycraft.fireStore.firestoreupload import FireStoreUpload
Initialize the FireStoreUpload class with the path to your Firebase service account credentials JSON file and the name of your Firebase Storage bucket.

python
Copy code
uploader = FireStoreUpload(credentials_path='path/to/firebase_credentials.json', storage_bucket='your_storage_bucket_name')
Uploading Files to Firebase Storage
upload_file Method
python
Copy code
# Upload a file to Firebase Storage
uploader.upload_file(local_file_path='path/to/local/file.txt')
local_file_path: The local path of the file to be uploaded.
Example Usage
python
Copy code
# Example usage of gsheetsdb
db = gsheetsdb(credentials_path='path/to/credentials.json', sheet_url='https://docs.google.com/spreadsheets/d/your_spreadsheet_id/edit')
data = db.read_sheet(key='column_name', number_of_rows=5, start_index=1, end_index=10)
df = db.in_pd()
json_data = db.in_json(target_key='column_name', num_rows=5, start_index=1, end_index=10)

# Example usage of FireStoreUpload
uploader = FireStoreUpload(credentials_path='path/to/firebase_credentials.json', storage_bucket='your_storage_bucket_name')
uploader.upload_file(local_file_path='path/to/local/file.txt')

Note: Make sure to replace placeholders such as path/to/credentials.json, your_spreadsheet_id, your_storage_bucket_name, etc., with your actual file paths and identifiers.