{"id":45589019,"url":"https://github.com/consilience/laravel-api-token-generator","last_synced_at":"2026-02-23T11:59:30.698Z","repository":{"id":56957463,"uuid":"194684680","full_name":"consilience/laravel-api-token-generator","owner":"consilience","description":"Artisan command to generate API tokens for any of your models in Laravel","archived":false,"fork":false,"pushed_at":"2019-11-27T15:12:29.000Z","size":25,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-29T16:13:57.455Z","etag":null,"topics":["api","api-token","laravel","laravel-api","lumen","lumen-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"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/consilience.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}},"created_at":"2019-07-01T14:06:09.000Z","updated_at":"2020-09-24T17:45:36.000Z","dependencies_parsed_at":"2022-08-21T04:40:24.052Z","dependency_job_id":null,"html_url":"https://github.com/consilience/laravel-api-token-generator","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/consilience/laravel-api-token-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consilience%2Flaravel-api-token-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consilience%2Flaravel-api-token-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consilience%2Flaravel-api-token-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consilience%2Flaravel-api-token-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/consilience","download_url":"https://codeload.github.com/consilience/laravel-api-token-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consilience%2Flaravel-api-token-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29742092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api","api-token","laravel","laravel-api","lumen","lumen-api"],"created_at":"2026-02-23T11:59:30.453Z","updated_at":"2026-02-23T11:59:30.688Z","avatar_url":"https://github.com/consilience.png","language":"PHP","readme":"# laravel-api-token-generator\n\nLaravel supports API token authentication out of the box.\nWhen developing, and for internal (machine-to-machine) APIs,\nit is useful to be able to generate tokens for a user.\nThis package provides a simple Artisan command to generate a token.\n\nThe token will be hashed using the `sha256` algorithm.\n\nThis package does not provide a database migration for the `api_token` column.\nThat is left to your application.\n\n## Installation\n\n### Installing with composer:\n\n`composer require consilience/laravel-api-token-generator`\n\n### Lumen\n\nFor Laravel, the service provider and configuration file are registered automatically.\nWith Lumen, additional entried are needed in `bootstrap/app.php`.\n\nThe service provider is registered:\n\n    $app-\u003eregister(Consilience\\Laravel\\ApiTokenGenerator\\Providers\\ServiceProvider::class);\n\nIf the configuration file is published, add:\n\n    $app-\u003econfigure('apitokens');\n\nthen copy `apitokens.php`:\n\n    cp vender/consilience/laravel-api-token-generator/apitokens.php config/apitokens.php\n\n### Publishing assets:\n\n`php artisan vendor:publish --provider=\"Consilience\\ApiTokenGenerator\\ApiTokenGeneratorServiceProvider\"`\n\n### Configuration\n\nYou can change the model that will hold the API tokens.\nBy default this will be `App\\User`, but yu may want `App\\Models\\User` for example.\n\n    'model' =\u003e App\\Models\\User::class,\n\nThe `name_field` is an alternative column to `id` that can be used to uniquely identify a model instance:\n\n    'name_field' =\u003e 'name'\n\nThe token column will be `api_token` by default, but can be changed:\n\n    'token_field' =\u003e 'my_api_token_column',\n\nNote: this package does not add the API token column to your users table.\nThat is a step for other packages or your application deployment.\n\n### Usage\n\nGenerate a new token or replace the existing token for a user:\n\n    php artisan apitoken:generate --id=123 --generate\n    php artisan apitoken:generate --id=5fd40c23-fcda-4bdc-a07c-f2bfeb56bb03 --generate\n\nThe `id` is normally an integer, but some this should also work if the `id` is a string such as *UUID*.\n\nA generated token will only be displayed once.\nIt is encrypted for saving against the model, so cannot be recovered if not recorded immediately.\n\nWhere users are uniquely identified by another column,\nthen that column can be used to identify the model instance to update with a new token:\n\n    php artisan apitoken:generate --name=bloggs@example.com --generate\n\nRather than generating a random token, you can set your own explicit tokanes.\nUse the `--token=` option to do this instead of the `--generate` option.\n\n    php artisan apitoken:generate --id=123 --token=d8a928b2043db77e340b523547bf16cb4aa483f0645fe0a290ed1f20aab76257\n\nIf using for automated deployment, you may want to use the `--no-ansi` option to remove control characters.\n\nThe `--check` option will tell you whether an instance has a token set or not:\n\n```bash\n$ php artisan apitoken:generate --id=11 --check\nApp\\Models\\User::11 has no API token set\nNo explicit token supplied (--token=) and no token to be generated (--generate)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconsilience%2Flaravel-api-token-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconsilience%2Flaravel-api-token-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconsilience%2Flaravel-api-token-generator/lists"}