Generate API Token within admin panel

As admin I would like to be able create or generate api toke via admin panel
10 Replies
toeknee
toeknee4w ago
Just build a resource to generate them.
Nicole
Nicole4w ago
What resource should I create?
toeknee
toeknee4w ago
The one to interact with your tokens table...
Nicole
Nicole3w ago
Is it the personal_access_tokens table, Sir?
toeknee
toeknee3w ago
So build a new Resource for the EPRsonal Access Tokens, or add personal access tokens as a relationship on the users resource if you have created one.
Nicole
Nicole3w ago
Can I create a resource with different name, let say "API Tokens" but the class I will be using is user? Because I already have resource for my user and I don't want to merge them, I want them in a separate resource.
awcodes
awcodes3w ago
you can tell the resource what model to use
protected static ?string $model = User::class;
protected static ?string $model = User::class;
toeknee
toeknee3w ago
Are your tokens attached to the user model or as a relationship of the user model?
Nicole
Nicole3w ago
I am using laravel sanctum so I believe it is attached to user Or do you think better to use the personal_access_tokens instead?
toeknee
toeknee3w ago
Fairly sure they have their own tokens table and it’s not part of the user table. Accessed via the trait