8000 GitHub - dongvuduc/the-bank: Bank Reconciliation System Import Data With OAuth2
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

dongvuduc/the-bank

Repository files navigation

Bank Reconciliation System Import Data With OAuth2

This package helps you authenticate users on a Laravel API based on JWT tokens generated from Laravel OAuth2.

Requirements

✔️ I`m building an API with Laravel.

✔️ Composer is need to run the command in Laravel. https://getcomposer.org/

✔️ I use Laravel Passport for authentication.

✔️ The frontend is a separated project: https://github.com/dongvuduc/the-office

✔️ The frontend users authenticate directly on Laravel OAuth2 to obtain a JWT token.

✔️ The frontend keep the JWT token from Server.

✔️ The frontend make requests to the Laravel API, with that token.

Install

Config Database in .env

Require the package

composer install

Create Database

php artisan migrate
php artisan db:seed

Run with port 8000 (Local Server 8000 - Frontend 8080)

php artisan serve --port 8000

Create new Client for OAuth2 (Optional)

php artisan passport:client

Account Demo

Username: admin@admin.com
Password: 12345678

Username: office@office.com
Password: 12345678

API

CLIENT ID AND SECRET

Login With OAuth2

Developers may use their client ID and secret to request an authorization code and access token from your application. First, the consuming application should make a redirect request to your application's like so:

GET http://SERVER_URL/oauth/authorize
{
    'client_id' => CLIENT_ID,
    'redirect_uri' => APP_URL_CALLBACK,
    'response_type' => 'code',
    'scope' => 'import'
}

Converting Authorization Codes To Access Tokens

If the user approves the authorization request, they will be redirected back to the consuming application. The request should include the authorization code that was issued by your application when the user approved the authorization request:

POST http://SERVER_URL/oauth/token
{
    'grant_type' => 'authorization_code',
    'client_id' => CLIENT_ID,
    'client_secret' => CLIENT_SECRET,
    'redirect_uri' => APP_URL_CALLBACK,
    'code' => AUTHORIZATION_CODE_FROM_SERVER,
}

Get Info User From Access Tokens

GET http://SERVER_URL/api/user
HEADER:
- Accept: application/json
- Authorization: Bearer access_tokens

Import File Data With Access Tokens

POST http://SERVER_URL/api/import
HEADER:
- Accept: application/json
- Authorization: Bearer access_tokens
{
    import_file: FILE_EXCEL_OR_CSV
}

TESTING

php artisan test

About

Bank Reconciliation System Import Data With OAuth2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0