コード例 #1
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 "lib/MongoOAuth2.php";
$oauth = new MongoOAuth2();
if ($_POST) {
    $oauth->finishClientAuthorization($_POST["accept"] == "Yep", $_POST);
}
try {
    $auth_params = $oauth->getAuthorizeParams();
} catch (OAuth2ServerException $oauthError) {
    $oauthError->sendHttpResponse();
}
?>
<html>
<head>
	Authorize
</head>
<body>
<form method="post" action="authorize.php">
	<?php 
foreach ($auth_params as $k => $v) {
    ?>
		<input type="hidden" name="<?php 
コード例 #2
0
ファイル: addclient.php プロジェクト: cjvaz/expressomail
<?php

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

<html>
<head>
Add Client
</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>
コード例 #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 "lib/MongoOAuth2.php";
$oauth = new MongoOAuth2();
try {
    $oauth->grantAccessToken();
} catch (OAuth2ServerException $oauthError) {
    $oauthError->sendHttpResponse();
}
コード例 #4
0
<?php

/**
 * @file
 * Sample protected resource.
 *
 * 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 "lib/MongoOAuth2.inc";
$oauth = new MongoOAuth2();
$oauth->verifyAccessToken();
// With a particular scope, you'd do:
// $oauth->verifyAccessToken("scope_name");
?>

<html>
  <head>
    <title>Hello!</title>
  </head>
  <body>
    <p>This is a secret.</p>
  </body>
</html>