Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstdmstd's avatar

How to implement external service api with sanctum?

Hello, I have Laravel 8 / blade / jQuery 3.5.1 / bootstrap 4.5.3 backend application with ads and I need to add external api with functionality like : a) Read our ads by some criteria b) Registered client can add ads to our database ... I added https://laravel.com/docs/8.x/sanctum to my app and use it as access token provider service to external api.

So I see it as next: When client fills special form (Register to services) he also select(subscribes) to several our services and on submit 1 row in personal_access_tokens will be added, like :

tokenable_type - not sure, what this field is for ? Some label like “Ads_Service” ? tokenable_id - not sure, what this field is for ? Reference to user.id(client must be registered at this table) name - not sure, what this field is for ?

token = returned token from Register to services form. This token would be used later for 'can_read_ads''can_add_ads' operations abilities = {'can_read_ads''can_add_ads', ‘some other service’} and for any selected functionality

last_used_at = when last operation was done.

How do you think ? What did I miss and what can be added?

Thanks!

0 likes
0 replies

Please or to participate in this conversation.