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

akrami's avatar

How can I create a custom auth provider that authenticate through an external API?

Hi I'm new to Laravel. I have an API that authenticates users and creates a JWT token for it. Now in my new app, I want to outsource authentication and authorization to this API. should I create a custom auth provider? How? could you provide an example!

0 likes
2 replies
martinbean's avatar

@akrami There aren’t any solid examples of custom auth providers because the implementation is very specific to a particular authentication provider.

If you’re wanting to authenticate against a third-party API, then you should probably create a custom user provider that fetches users from this API. The Laravel documentation has information on the contract and the methods you need to implement in any custom user providers: https://laravel.com/docs/master/authentication#adding-custom-user-providers

2 likes

Please or to participate in this conversation.