etape3
This commit is contained in:
78
docs/pedagogie/oauth-test-manuel.md
Normal file
78
docs/pedagogie/oauth-test-manuel.md
Normal file
@@ -0,0 +1,78 @@
|
||||
# OAuth 42 — tests manuels des URLs
|
||||
|
||||
## Pourquoi pas `http://localhost` sur téléphone ?
|
||||
|
||||
| Environnement | `http://localhost:8080/callback` |
|
||||
|---------------|----------------------------------|
|
||||
| Émulateur Android | Parfois OK (localhost = l’émulateur) |
|
||||
| **Téléphone physique** | ❌ « Site inaccessible » — localhost = le téléphone, pas ton PC |
|
||||
|
||||
**Swifty Companion (mobile réel)** : utiliser un **schéma d’app** :
|
||||
|
||||
```text
|
||||
com.example.swiftycompanion://callback
|
||||
```
|
||||
|
||||
À enregistrer sur l’Intra **et** dans `.env` (`REDIRECT_URI`).
|
||||
|
||||
---
|
||||
|
||||
## Endpoints 42 (référence sujet)
|
||||
|
||||
| Rôle | URL |
|
||||
|------|-----|
|
||||
| Autorisation | `https://api.intra.42.fr/oauth/authorize` |
|
||||
| Token | `https://api.intra.42.fr/oauth/token` |
|
||||
| API (ex. moi) | `https://api.intra.42.fr/v2/me` |
|
||||
|
||||
Doc : [api.intra.42.fr/apidoc](https://api.intra.42.fr/apidoc)
|
||||
|
||||
---
|
||||
|
||||
## 1. Tester l’API (sans app)
|
||||
|
||||
Dans un navigateur (connecté à l’Intra ou non pour cette étape) :
|
||||
|
||||
```text
|
||||
https://api.intra.42.fr/
|
||||
```
|
||||
|
||||
Réponse JSON attendue (message API) → l’API est joignable.
|
||||
|
||||
---
|
||||
|
||||
## 2. Tester la page d’autorisation (navigateur)
|
||||
|
||||
Remplace `TON_CLIENT_ID` par l’**UID** de ton app OAuth.
|
||||
|
||||
**Redirect actuel (mobile)** :
|
||||
|
||||
```text
|
||||
https://api.intra.42.fr/oauth/authorize?client_id=TON_CLIENT_ID&redirect_uri=com.example.swiftycompanion%3A%2F%2Fcallback&response_type=code&scope=public
|
||||
```
|
||||
|
||||
| Résultat | Signification |
|
||||
|----------|----------------|
|
||||
| Page login / autorisation 42 | ✅ URL d’auth OK |
|
||||
| Erreur `redirect_uri` | ❌ URI pas enregistrée sur l’Intra ou différente de `.env` |
|
||||
| Erreur `invalid_client` | ❌ `client_id` incorrect |
|
||||
|
||||
Après validation, le navigateur tente d’ouvrir `com.example.swiftycompanion://callback?code=...` → sur PC ça échoue (normal) ; **sur le téléphone avec l’app installée**, l’app doit s’ouvrir.
|
||||
|
||||
---
|
||||
|
||||
## 3. Alignement obligatoire (3 endroits identiques)
|
||||
|
||||
1. [Application OAuth Intra](https://profile.intra.42.fr/oauth/applications) → **URI de redirection**
|
||||
2. `swifty_companion/.env` → `REDIRECT_URI=...`
|
||||
3. Code Flutter → même valeur via `IntraConfig.redirectUri`
|
||||
|
||||
---
|
||||
|
||||
## 4. Ancien redirect (à retirer sur l’Intra si présent)
|
||||
|
||||
```text
|
||||
http://localhost:8080/callback
|
||||
```
|
||||
|
||||
Remplacer par `com.example.swiftycompanion://callback` (une ligne dans le formulaire).
|
||||
Reference in New Issue
Block a user