mimso/oauth-client-php

This package is abandoned and no longer maintained. No replacement package was suggested.

Authentification with social network

1.1 2021-06-13 23:20 UTC

This package is auto-updated.

Last update: 2023-01-14 02:35:59 UTC


README

Requirements

Installation

Download and install Composer by following the official instructions.

For usage, see the documentation.

Run this command to install the package with composer

composer require mimso/oauth-client-php

Usage

Example for google oauth API.

$oauth = new \Mnt\OAuth\OAuth([
    'clientId'                => '0000',
    'clientSecret'            => '0000',
    'redirectUri'             => 'https://my.url/',
    'authEndpoint'            => 'https://accounts.google.com/o/oauth2/v2/auth',
    'accessTokenEndpoint'     => 'https://oauth2.googleapis.com/token',
    'userInfoEndpoint'        => 'https://openidconnect.googleapis.com/v1/userinfo',
    'scope'                   => ['openid', 'email', 'profile'],
]);

if(isset($_GET['code'])) {
    $accessToken = $oauth->getToken($_GET['code']);
    $user = $oauth->getResource();
    var_dump($user) //logged
} else {
    echo "<a href=". $oauth->getAuthUrl() .">login with google</a>";
}

License

oauth-client-php is available under MIT LICENSE.