PHP code example of adaojunior / passport-social-grant

1. Go to this page and download the library: Download adaojunior/passport-social-grant 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/ */

    

adaojunior / passport-social-grant example snippets


'providers' => [
    // ...
    Adaojunior\PassportSocialGrant\SocialGrantServiceProvider::class,
];



namespace App\SocialGrant;

use Laravel\Socialite\Facades\Socialite;
use Illuminate\Contracts\Auth\Authenticatable;
use League\OAuth2\Server\Entities\ClientEntityInterface;
use Adaojunior\PassportSocialGrant\SocialGrantUserProvider;

class UserProvider implements SocialGrantUserProvider
{
    /**
     * Retrieve a user by provider and access token.
     *
     * @param string $provider
     * @param string $accessToken
     * @param ClientEntityInterface $client
     * @return Authenticatable|null
     */
    public function getUserByAccessToken(string $provider, string $accessToken, ClientEntityInterface $client):? Authenticatable
    {

    }
}

$this->app->bind(
    Adaojunior\PassportSocialGrant\SocialGrantUserProvider::class,
    App\SocialGrant\UserProvider::class
);

$response = $http->post('http://your.app/oauth/token', [
    'form_params' => [
        'grant_type' => 'social',
        'client_id' => $clientId,
        'client_secret' => $clientSecret,
        'provider' => $providerName, // name of provider (e.g., 'facebook', 'google' etc.)
        'access_token' => $providerAccessToken, // access token issued by specified provider
    ],
]);