{"id":15652719,"url":"https://github.com/iamnotstatic/laravel-api-auth","last_synced_at":"2025-04-30T20:23:51.091Z","repository":{"id":45480350,"uuid":"253286964","full_name":"iamnotstatic/laravel-api-auth","owner":"iamnotstatic","description":"A Laravel Package for easy API authentication setup with passport","archived":false,"fork":false,"pushed_at":"2020-04-10T16:45:58.000Z","size":40,"stargazers_count":30,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T19:36:28.019Z","etag":null,"topics":["laravel","laravel-api","laravel-authentication","laravel-passport","oauth2-laravel"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamnotstatic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-05T17:01:58.000Z","updated_at":"2025-02-26T00:42:23.000Z","dependencies_parsed_at":"2022-07-15T03:30:34.138Z","dependency_job_id":null,"html_url":"https://github.com/iamnotstatic/laravel-api-auth","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnotstatic%2Flaravel-api-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnotstatic%2Flaravel-api-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnotstatic%2Flaravel-api-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnotstatic%2Flaravel-api-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamnotstatic","download_url":"https://codeload.github.com/iamnotstatic/laravel-api-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251775831,"owners_count":21641888,"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","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":["laravel","laravel-api","laravel-authentication","laravel-passport","oauth2-laravel"],"created_at":"2024-10-03T12:43:32.517Z","updated_at":"2025-04-30T20:23:51.064Z","avatar_url":"https://github.com/iamnotstatic.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel API Auth\n\n[![GitHub issues](https://img.shields.io/github/issues/iamnotstatic/laravel-api-auth)](https://github.com/iamnotstatic/laravel-api-auth/issues)\n[![GitHub stars](https://img.shields.io/github/stars/iamnotstatic/laravel-api-auth)](https://github.com/iamnotstatic/laravel-api-auth/stargazers)\n[![GitHub license](https://img.shields.io/github/license/iamnotstatic/laravel-api-auth)](https://github.com/iamnotstatic/laravel-api-auth)\n[![Total Downloads](https://img.shields.io/packagist/dt/iamnotstatic/laravel-api-auth)](https://github.com/iamnotstatic/laravel-api-auth)\n\n## Introduction\n\n\u003e A Laravel Package for easy API authentication setup with passport\n\n## Installation\n\nTo get the latest version of Laravel Api Auth, simply require it\n\n```bash\ncomposer require iamnotstatic/laravel-api-auth\n```\n\n## Configuration\n\nYou can publish the configuration file using this command:\n\n```bash\nphp artisan vendor:publish --provider=\"Iamnotstatic\\LaravelAPIAuth\\LaravelAPIAuthServiceProvider\"\n```\n\nMigrate your database after installing the package\n\n```bash\nphp artisan migrate\n```\n\nThis command will create the encryption keys needed to generate secure access tokens. In addition, the command will create \"personal access\" and \"password grant\" clients which will be used to generate access tokens\n\n```bash\nphp artisan passport:install\n```\n\nNext, you should call the Passport::routes method within the boot method of your AuthServiceProvider. This method will register the routes necessary to issue access tokens and revoke access tokens, clients, and personal access tokens:\n\n```php\n\u003c?php\n\nnamespace App\\Providers;\n\nuse Illuminate\\Foundation\\Support\\Providers\\AuthServiceProvider as ServiceProvider;\nuse Illuminate\\Support\\Facades\\Gate;\nuse Laravel\\Passport\\Passport;\n\nclass AuthServiceProvider extends ServiceProvider\n{\n    /**\n     * The policy mappings for the application.\n     *\n     * @var array\n     */\n    protected $policies = [\n        'App\\Model' =\u003e 'App\\Policies\\ModelPolicy',\n    ];\n\n    /**\n     * Register any authentication / authorization services.\n     *\n     * @return void\n     */\n    public function boot()\n    {\n        $this-\u003eregisterPolicies();\n\n        Passport::routes();\n    }\n}\n```\n\nIn your config/auth.php configuration file, you should set the driver option of the api authentication guard to passport. This will instruct your application to use Passport's TokenGuard when authenticating incoming API requests:\n\n```php\n'guards' =\u003e [\n    'web' =\u003e [\n        'driver' =\u003e 'session',\n        'provider' =\u003e 'users',\n    ],\n\n    'api' =\u003e [\n        'driver' =\u003e 'passport',\n        'provider' =\u003e 'users',\n    ],\n],\n```\n\nIn your config/auth.php configuration file, you should set the model option of the package model. This will provide a few helper methods to allow you to inspect the authenticated user's token and scopes:\n\n```php\n'providers' =\u003e [\n        'users' =\u003e [\n            'driver' =\u003e 'eloquent',\n            'model' =\u003e Iamnotstatic\\LaravelAPIAuth\\Models\\User::class,\n        ],\n\n        // 'users' =\u003e [\n        //     'driver' =\u003e 'database',\n        //     'table' =\u003e 'users',\n        // ],\n    ],\n```\n\n## Usage\n\nNow, we can simple test by rest client tools (Postman), So I test it and you can see below screenshots.\n\n\u003e In this api you have to set two header as listed below:\n\n```bash\nAccept: application/json\n```\n\n![pkg imgs](https://user-images.githubusercontent.com/46509072/78991850-d1b2ee80-7b31-11ea-8c90-e588fe7789ab.png)\n\nRegister\n\n![register](https://user-images.githubusercontent.com/46509072/78993042-bc8b8f00-7b34-11ea-8eb4-449c7f82fd3f.png)\n\nLogin\n\n![login](https://user-images.githubusercontent.com/46509072/78993086-d3ca7c80-7b34-11ea-807f-8bbf7baa00e8.png)\n\nLogout\n\n![logout](https://user-images.githubusercontent.com/46509072/78993159-f8beef80-7b34-11ea-9f0e-bff2dda268d8.png)\n\nGet User\n\n![getuser](https://user-images.githubusercontent.com/46509072/78993121-e93fa680-7b34-11ea-98da-6ff837f52b78.png)\n\nForgotten Password\n\n![forgottenpass](https://user-images.githubusercontent.com/46509072/78993185-0d02ec80-7b35-11ea-888b-d1ff379170c8.png)\n\nReset Passowrd\n\n![passwordreset](https://user-images.githubusercontent.com/46509072/78993214-1e4bf900-7b35-11ea-9c2b-346e1f555b97.png)\n\n## Contributing\n\nPlease feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.\n\n## How can I thank you?\n\nWhy not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or HackerNews? Spread the word!\n\nDon't forget to [follow me on twitter](https://twitter.com/iamnotstatic)!\n\nThanks!\nAbdulfatai Suleiman.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamnotstatic%2Flaravel-api-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamnotstatic%2Flaravel-api-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamnotstatic%2Flaravel-api-auth/lists"}