Skip to content

UlrichHP/p7_bilemo

Repository files navigation

Projet 7 - Créez un site e-commerce exposant une API

Cette API a été réalisé pour le projet 7 du parcours Développeur d'application - PHP / Symfony d'OpenClassrooms. J'ai utilisé comme base Symfony Standard Edition.

Les diagrammes de ce projet sont dans le dossier UML.

This API has been made for the seventh project of OpenClassrooms path Application Developer - PHP / Symfony. I used Symfony Standard Edition as a starter.

In the UML folder, you can find the diagrams of this project.

Installation

Clonez le repository GitHub et tapez les commandes suivantes :

  • Entrez vos identifiants de connexion à la base de données dans app/config/parameters.yml
  • composer install
  • php bin/console doctrine:database:create
  • php bin/console doctrine:schema:create
  • php bin/console doctrine:fixtures:load (si vous voulez utiliser les fixtures)

Pour créer un Client :

  • php bin/console CreateClient --redirect_url=WEBSITE_URL

Vos identifiants d'API (client_id et client_secret) seront écrits en réponse.

Comment créer un utilisateur :

  • Voir BileMo_doc : /register

La méthode d'autorisation de cette API est : Resource Owner Password Credentials Grant.

Comment avoir un Token d'accès : Faites une requête POST sur /oauth/v2/token avec les paramètres suivants :

  • client_id = YOUR_CLIENT_ID
  • client_secret = YOUR_CLIENT_SECRET
  • redirect_uri = REDIRECT_URI (Optionnel)
  • grant_type = password
  • username = YOUR_USERNAME
  • password = YOUR_PASSWORD

Comment utiliser un Token de rafraîchissement : Faites une requête POST sur /oauth/v2/token avec les paramètres suivants :

  • client_id = YOUR_CLIENT_ID
  • client_secret = YOUR_CLIENT_SECRET
  • grant_type = refresh_token
  • refresh_token = YOUR_REFRESH_TOKEN

Pour accèder à l'API, il faut ensuite envoyer une requête avec un en-tête de type Authorization = 'Bearer ' + le token de l'utilisateur.

La documentation de l'API se trouve dans le fichier BileMo_doc.md et vous pouvez également la consulter en ligne à l'adresse /api/doc.

Vous pouvez également tester l'API avec BileMo_App.

Clone the GitHub repository and execute the following commands :

  • Enter your database settings in app/config/parameters.yml
  • composer install
  • php bin/console doctrine:database:create
  • php bin/console doctrine:schema:create
  • php bin/console doctrine:fixtures:load (if you want to use fixtures)

To create a Client:

  • php bin/console CreateClient --redirect_url=WEBSITE_URL

Your API credentials (client_id and client_secret) will be written in response.

How to create a user:

  • See BileMo_doc : /register

The Authorization type for this API is : Resource Owner Password Credentials Grant.

How to get an Access Token: Make a POST request on /oauth/v2/token with the following parameters:

  • client_id = YOUR_CLIENT_ID
  • client_secret = YOUR_CLIENT_SECRET
  • redirect_uri = REDIRECT_URI (Optional)
  • grant_type = password
  • username = YOUR_USERNAME
  • password = YOUR_PASSWORD

How to use a Refresh Token: Make a POST request on /oauth/v2/token with the following parameters:

  • client_id = YOUR_CLIENT_ID
  • client_secret = YOUR_CLIENT_SECRET
  • grant_type = refresh_token
  • refresh_token = YOUR_REFRESH_TOKEN

To access the API, you have to send a request with a header Authorization = 'Bearer ' + the user's token.

The API documentation is located in the BileMo_doc.md file and you can see it online at /api/doc.

You can also test this API with BileMo_App.

Symfony Standard Edition

Welcome to the Symfony Standard Edition - a fully-functional Symfony application that you can use as the skeleton for your new applications.

For details on how to download and get started with Symfony, see the Installation chapter of the Symfony Documentation.

All libraries and bundles included in the Symfony Standard Edition are released under the MIT or BSD license.

About

OpenClassrooms Project 7 DA - PHP / Symfony

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published