Skip to content

Retrive all countries with their area using authentication JWT (Json Web Token) in laravel

Notifications You must be signed in to change notification settings

Eslam-Ayman/SoleekLab-JWT

Repository files navigation

Documentation of SoleekLab (JWT LARAVEL API)

About

This project is for testing my skills in RESTFul API & Auth JWT with Laravel . SoleeLab is a RESTful API Project with 3 APIs for mobile app to help to get all countries with thier area in KM2

To Run

You will need:

Setup / configuration

  1. clone Repo
    • git clone https://github.com/Eslam-Ayman/SoleekLab-JWT.git
    • cd into your project
  2. Install Composer Dependencies
    • composer install
  3. Create a copy of your .env file
    • cp .env.example .env
  4. Generate an app encryption key
    • php artisan key:generate
    • If the application key is not set, your user sessions and other encrypted data will not be secure!
  5. Create an empty database for our application
  6. In the .env file, add database information to allow Laravel to connect to the database
  7. Migrate the database
    • php artisian migrate
    • if you don't need to migrate so import soleeklab.sql in your DB
    • and after that you must run php artisian migrate
  8. Run the following command to publish the package config file:
    • php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
    • You should now have a config/jwt.php file that allows you to configure the basics of this package.
  9. you have to generate a key for JWT:
    • php artisan jwt:secret
    • This will update your .env file with something like JWT_SECRET=foobar
    • It is the key that will be used to sign your tokens. How that happens exactly will depend on the algorithm that you choose to use.
  10. run this command php artisan serve

Start using API

Name Method URL Header Body ( RAW ) not (form-data)
Login POST http://127.0.0.1:8000/api/login Content-Type: application/json
Accept: application/json
Required Data: (email, password)
Optional Data: (null)
Register POST http://127.0.0.1:8000/api/register Content-Type: application/json
Accept: application/json
Required Data: (name, email, password, password_confirmation)
Optional Data: (null)
Area GET http://127.0.0.1:8000/api/area Content-Type: application/json
Accept: application/json
Authorization: Bearer
null

Note: if you want to send data in Body Format (form-data) so you must remove Content-Type from Header

Program's Output

N|Solid

Resources / References

public API about list of countries

JWT-Auth Documentation of jwt-auth && Repo of jwt-auth

Unirest is a set of lightweight HTTP libraries available in multiple languages. i used this library to get json data from another Public API witch is list of all countries in the world unirest php library to install it using composer composer require mashape/unirest-php

License

GNU GPL License

Author : Eslam Ayman

About

Retrive all countries with their area using authentication JWT (Json Web Token) in laravel

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published