PHP code example of zfr / zfr-oauth2-server-module

1. Go to this page and download the library: Download zfr/zfr-oauth2-server-module library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zfr / zfr-oauth2-server-module example snippets


use Application\Entity\User;
use ZfrOAuth2\Server\Entity\TokenOwnerInterface;

return [
    'doctrine' => [
        'entity_resolver' => [
            'orm_default' => [
                TokenOwnerInterface::class => Application\Entity\User::class
            ]
        ]
    ]
]

use ZfrOAuth2\Server\Grant\PasswordGrant;
use ZfrOAuth2\Server\Grant\RefreshTokenGrant';

return [
    'zfr_oauth2_server' => [
        'grants' => [
            PasswordGrant::class,
            RefreshTokenGrant::class
        ]
    ]
]

return [
    'zfr_oauth2_server' => [
        'owner_callable' => function($username, $password) {
            // If valid, return the user, otherwise return null
        }
    ]
];