Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Oauth2 Server Laravel Laravel Package

lucadegasperi/oauth2-server-laravel

View on GitHub
Deep Wiki
Context7

Implementing an Authorization Server with the Password Grant

  1. To enable this grant add the following to the config/oauth2.php configuration file.

    'grant_types' => [
        'password' => [
            'class' => '\League\OAuth2\Server\Grant\PasswordGrant',
            'callback' => '\App\PasswordGrantVerifier@verify',
            'access_token_ttl' => 3600
        ]
    ]
    
  2. Create a class with a verify method where you check if the provided user is a valid one. In the following example you have to create a PasswordGrantVerifier.php in your app folder.

    namespace App;
    
    use Illuminate\Support\Facades\Auth;
    
    class PasswordGrantVerifier
    {
      public function verify($username, $password)
      {
          $credentials = [
            'email'    => $username,
            'password' => $password,
          ];
    
          if (Auth::once($credentials)) {
              return Auth::user()->id;
          }
    
          return false;
      }
    }
    
  3. Next add a sample client to the oauth_clients table.

  4. Finally set up a route to respond to the incoming access token requests.

    Route::post('oauth/access_token', function() {
        return Response::json(Authorizer::issueAccessToken());
    });
    

← Back to start

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui