Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

TutsPlus.com:
Set Up an OAuth2 Server Using Passport in Laravel
Jun 08, 2018 @ 11:51:36

The TutsPlus.com site has a new tutorial posted showing you how to create an OAuth2 server with Laravel and the help of the Passport library.

In this article, we’re going to explore how you could set up a fully fledged OAuth2 server in Laravel using the Laravel Passport library. We’ll go through the necessary server configurations along with a real-world example to demonstrate how you could consume OAuth2 APIs.

I assume that you’re familiar with the basic OAuth2 concepts and flow as we’re going to discuss them in the context of Laravel. In fact, the Laravel Passport library makes it pretty easy to quickly set up an OAuth2 server in your application. Thus, other third-party applications are able to consume APIs provided by your application.

The article is then divided up into the steps (code, configuration changes, and commands) required to get the system up and running:

  • Installation of Passport (requires a Laravel app already installed)
  • Changing the User model to add the "remember_token" field
  • Setting up some demo resources
  • Adding the middleware and routes to handle the requests

The tutorial then spends some time showing how to consume OAuth2 APIs and makes use of the Passport "client" to make some sample requests. Finally, it walks you through the whole process of the OAuth2 experience from a user perspective, including some code to manually make the connection from plain PHP.

tagged: tutorial oauth2 server laravel passport client token

Link: https://code.tutsplus.com/tutorials/setup-oauth2-server-using-passport-in-laravel--cms-30576