PHP code example of deminoth / oauth2-naver

1. Go to this page and download the library: Download deminoth/oauth2-naver 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/ */

    

deminoth / oauth2-naver example snippets


$provider = new \Deminoth\OAuth2\Client\Provider\Naver([
    'clientId' => "YOUR_CLIENT_ID",
    'clientSecret' => "YOUR_CLIENT_SECRET",
    'redirectUri' => "http://your-redirect-uri"
]);


if (isset($_GET['code']) && $_GET['code']) {
    $token = $this->provider->getAccessToken("authorizaton_code", [
        'code' => $_GET['code']
    ]);

    $user = $this->provider->getUserDetails($token);

    // $user->uid = [ encoded Naver ID ]
    // $user->nickname = [ Naver nickname ]
    // $user->imageUrl = [ Profile Image ]
    // $user->email = [ [email protected] ]
}