PHP code example of easybib / stack-github-org-auth

1. Go to this page and download the library: Download easybib/stack-github-org-auth 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/ */

    

easybib / stack-github-org-auth example snippets


$stack = (new Stack\Builder())
    ->push('Stack\Session')
    ->push(
        'Igorw\Stack\OAuth',
        [
            'key' => $app['github.key'],
            'secret' => $app['github.secret'],
            'callback_url' => $app['github.callback'],
            'success_url' => $app['url_generator']->generate('homepage'),
            'failure_url'  => '/auth',
            'oauth_service.class' => 'OAuth\OAuth2\Service\GitHub',
            'service_scopes' => [
                'read:org',
            ],
        ]
    )
    ->push(
        'ImagineEasy\Stack\GitHubOrgAuth',
        [
            'organizations' => ['easybiblabs'],
            // the following options are optional
            'github_org_url' => 'https://api.github.com/user/orgs?access_token=' // e.g. for GitHub Enterprise
            'http_client' => new GuzzleHttp\Client,
            'session_orgs' => 'github.orgs', // defines the key used in the session

        ]
    )
;

$app = $stack->resolve($app);

$request = HttpFoundation\Request::createFromGlobals();
$response = $app->handle($request)->send();
$app->terminate($request, $response);