{"id":15160030,"url":"https://github.com/cba85/laravel7-passport","last_synced_at":"2025-09-30T10:31:04.635Z","repository":{"id":190896256,"uuid":"249158691","full_name":"cba85/laravel7-passport","owner":"cba85","description":"🔐 Laravel 7 Passport OAuth","archived":true,"fork":false,"pushed_at":"2020-03-22T12:09:51.000Z","size":534,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-20T02:38:21.986Z","etag":null,"topics":["laravel7","php72"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cba85.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-03-22T10:21:52.000Z","updated_at":"2023-08-26T22:34:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"3158a7bf-e460-489a-b06e-291984b60477","html_url":"https://github.com/cba85/laravel7-passport","commit_stats":null,"previous_names":["cba85/laravel7-passport"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cba85/laravel7-passport","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cba85%2Flaravel7-passport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cba85%2Flaravel7-passport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cba85%2Flaravel7-passport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cba85%2Flaravel7-passport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cba85","download_url":"https://codeload.github.com/cba85/laravel7-passport/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cba85%2Flaravel7-passport/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277673189,"owners_count":25857636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-30T02:00:09.208Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel7","php72"],"created_at":"2024-09-26T22:04:00.083Z","updated_at":"2025-09-30T10:31:04.275Z","avatar_url":"https://github.com/cba85.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel SPA\n\nhttps://www.grafikart.fr/tutoriels/laravel-passport-oauth-978\n\n## 1. Set up web auth\n\nhttps://laravel.com/docs/7.x/authentication\n\n-   Create a user to use it with the API\n\n## 2. Set up Laravel passeport\n\nhttps://laravel.com/docs/7.x/passport#frontend-quickstart\n\n## 3. Use Laravel Passeport : Password grant\n\n```\n$ php artisan passport:client --password\n```\n\n### Get token\n\nUse Postman:\n\n```\ncurl --location --request POST 'http://localhost:8000/oauth/token' \\\n--header 'Content-Type: multipart/form-data; boundary=--------------------------141827371592682820766257' \\\n--form 'grant_type=password' \\\n--form 'client_id=4' \\\n--form 'client_secret=j3bJwMGXisgiHgvKqctPq16dhFYyL7Ep8b16cYUa' \\\n--form 'username=clement@webstart.com' \\\n--form 'password=azertyuiop'\n```\n\n## 4. Use Laravel Passeport : Authorization code grand\n\n### 1. Dans le navigateur :\n\n-   http://localhost:8000/oauth/authorize?client_id=3\u0026redirect=http%3A%2F%2Flocalhost:8000%2Fauth%2Fcallback\u0026response_type=code\n\nOn récupérer le code dans l'url de la réponse en 404.\n\n### 2. Dans Postman :\n\n-   POST\n-   http://localhost:8000/oauth/token\n\n```\n{\n\t\"grant_type\": \"authorization_code\",\n\t\"client_id\": 3,\n\t\"client_secret\": \"WoFieFkgcKkj7aSkU2dCtnr002M5CJCsPKsQrWiT\",\n\t\"redirect_uri\": \"http://localhost:8000/auth/callback\",\n\t\"code\": \"def502002792c3d0906429ecbc12a0b0622581fa0b3784f2ec358fd6933319906720032b654867dec99ffc14bac88c24a910028500e3cf945cb9cb5307626d32ed46fa68dc7a494fb861029ef7545f79859a66530072bc3cb32e75560de6be0e6669c1182680b39246a3c5d697a61e3891d81bb516f9bb6d8b4e11df39e8491709b64bd7531721ce8e653ec527f9026a9a4f4ee53bf3ba282f6d67a92e4eaf0838be096aa9b2e2a0f85f51de7b7b2a0d11fd3925d7bce50451efd2493970fccea27062ef5d5c92fa1ecbd6b3ab463588a2cbaf68b2b62ef4b9418b729faab9463bc8eb567a0b2be1ab36c7dea7920c26eaab85ca16813c7deef475eac0b54adc50856f0b42166b044d8728eef04f6d587b237f5d2dc38518ccd8980daac9cf19d068e08f2e35f0b603d15d6294b9ed504de43fcc75e5f7605599755d66ecac354e4e9b292e85bacbac35c11a30399a21db1c72e8eea41b12050027941de7f65f025b5a9a\"\n}\n```\n\n### 3. Test de l'API dans Postman:\n\n-   GET\n-   http://localhost:8000/api/user\n    -   Renvoi le formulaire de login\n    -   Si on ajout un header : `Accept: application/json`\n        -   Renvoi `{\"message\":\"Unauthenticated.\"}`\n    -   Si on ajoute aussi l'access token qui est un Bearer Token dans Authorization de Postman : on récupère les informations utilisateurs\n\n## 5. Scopes\n\n-   Créer les scopes dans `AuthServiceProvider.php`\n-   Créer les routes avec les middlewares scope\n-   Ajouter les scopes au `Kernel.php` (http);\n\n-   GET\n-   http://localhost:8000/oauth/authorize?client_id=3\u0026redirect=http%3A%2F%2Flocalhost:8000%2Fauth%2Fcallback\u0026response_type=code\u0026scope=admin\n-   Obtenir un nouveau code et refaire la requête http://localhost:8000/oauth/token pour obtenir de nouveaux tokens\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcba85%2Flaravel7-passport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcba85%2Flaravel7-passport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcba85%2Flaravel7-passport/lists"}