53 lines
1.4 KiB
Python
53 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test simple avec les emails comme usernames
|
|
"""
|
|
|
|
import requests
|
|
|
|
def test_email_auth():
|
|
base_url = "http://localhost:8180"
|
|
|
|
print("🧪 Test d'authentification avec emails comme usernames")
|
|
print()
|
|
|
|
# Test avec marie.active@unionflow.com
|
|
email_username = "marie.active@unionflow.com"
|
|
password = "Marie123!"
|
|
|
|
print(f"Test de {email_username} avec mot de passe {password}")
|
|
|
|
data = {
|
|
"username": email_username,
|
|
"password": password,
|
|
"grant_type": "password",
|
|
"client_id": "unionflow-mobile"
|
|
}
|
|
|
|
try:
|
|
response = requests.post(
|
|
f"{base_url}/realms/unionflow/protocol/openid-connect/token",
|
|
data=data,
|
|
headers={"Content-Type": "application/x-www-form-urlencoded"}
|
|
)
|
|
|
|
print(f"Status: {response.status_code}")
|
|
print(f"Response: {response.text}")
|
|
|
|
if response.status_code == 200:
|
|
token_data = response.json()
|
|
if "access_token" in token_data:
|
|
print("✅ AUTHENTIFICATION RÉUSSIE !")
|
|
print(f"Token reçu (longueur: {len(token_data['access_token'])})")
|
|
return True
|
|
|
|
print("❌ Authentification échouée")
|
|
return False
|
|
|
|
except Exception as e:
|
|
print(f"Erreur: {e}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
test_email_auth()
|