Ejemplo n.º 1
0
session_start();
//Set manual token to cookies
if (isset($_POST['token'])) {
    setcookie("yaAccessToken", $_POST['token'], null, '/');
}
if (isset($_REQUEST['back'])) {
    $_SESSION['back'] = $_REQUEST['back'];
}
use Yandex\OAuth\OAuthClient;
// Client secret is not required in this case
$client = new OAuthClient($settings['global']['clientId']);
$state = 'yandex-php-library';
if (isset($_REQUEST['type'])) {
    switch ($_REQUEST['type']) {
        case 'code':
            $client->authRedirect(true, OAuthClient::CODE_AUTH_TYPE, $state);
            break;
        case 'token':
            $client->authRedirect(true, OAuthClient::TOKEN_AUTH_TYPE, $state);
            break;
        default:
            // do nothing
            break;
    }
}
?>
<!doctype html>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>Yandex PHP Library: OAuth Demo</title>