Пример #1
0
<?php

/**
 * @file
 * Sample client add script.
 *
 * Obviously not production-ready code, just simple and to the point.
 */
require 'OAuth2/Server/MongoServer.php';
if ($_POST && isset($_POST["client_id"]) && isset($_POST["client_secret"]) && isset($_POST["redirect_uri"])) {
    $oauth = new OAuth2\Server\MongoServer();
    $oauth->addClient($_POST["client_id"], $_POST["client_secret"], $_POST["redirect_uri"]);
}
?>

<html>
<head>
<title>Add Client</title>
</head>
<body>
<form method="post" action="addclient.php">
<p><label for="client_id">Client ID:</label> <input type="text"
    name="client_id" id="client_id" /></p>
<p><label for="client_secret">Client Secret (password/key):</label> <input
    type="text" name="client_secret" id="client_secret" /></p>
<p><label for="redirect_uri">Redirect URI:</label> <input type="text"
    name="redirect_uri" id="redirect_uri" /></p>
<input type="submit" value="Submit" /></form>
</body>
</html>
Пример #2
0
<?php

/**
 * @file
 * Sample authorize endpoint.
 *
 * Obviously not production-ready code, just simple and to the point.
 *
 * In reality, you'd probably use a nifty framework to handle most of the crud for you.
 */
require 'OAuth2/Server/MongoServer.php';
require_once 'OAuth2/Exception/ServerException.php';
$oauth = new OAuth2\Server\MongoServer();
if ($_POST) {
    $oauth->finishClientAuthorization($_POST["accept"] == "Yep", $_POST);
}
try {
    $auth_params = $oauth->getAuthorizeParams();
} catch (OAuth2\Exception\ServerException $oauthError) {
    $oauthError->sendHttpResponse();
}
?>
<html>
<head>
<title>Authorize</title>
</head>
<body>
<form method="post" action="authorize.php">
      <?php 
foreach ($auth_params as $k => $v) {
    ?>
Пример #3
0
<?php

/**
 * @file
 * Sample token endpoint.
 *
 * Obviously not production-ready code, just simple and to the point.
 *
 * In reality, you'd probably use a nifty framework to handle most of the crud for you.
 */
require 'OAuth2/Server/MongoServer.php';
require 'OAuth2/Excepton/ServerException.php';
$oauth = new OAuth2\Server\MongoServer();
try {
    $oauth->grantAccessToken();
} catch (OAuth2\Exception\ServerException $oauthError) {
    $oauthError->sendHttpResponse();
}