Example #1
0
 public function post_token()
 {
     $oA = new SebRenauld\OAuth2();
     $r = $oA->grantAccessToken(Input::all());
     if ($r instanceof Response) {
         return $r;
     }
     var_dump($r);
     die;
 }
Example #2
0
Autoloader::map(array(
// Required models. Feel free to mock those 
"SebRenauld\OAuth2\Models\Scope" => dirname(__FILE__).DS."models".DS."scope.php",
"SebRenauld\OAuth2\Models\Client" => dirname(__FILE__).DS."models".DS."client.php",
"SebRenauld\OAuth2\Models\Token" => dirname(__FILE__).DS."models".DS."token.php",

// The actual library 
"SebRenauld\OAuth2" => dirname(__FILE__).DS."libraries".DS."oauth2.php"
));
*/
Route::filter("oauth2", function () {
    $t = Input::get("oauth_token");
    if (!$t) {
        return Response::error(403);
    }
    if (($r = SebRenauld\OAuth2::verify($t)) === false) {
        return Response::error(403);
    }
});
Event::listen("oauth2.error.json", function ($r, $code) {
    $c = explode(":", $code);
    $msg = array_pop($c);
    if (count($c)) {
        $statusCode = array_pop($c);
    } else {
        $statusCode = 200;
    }
    return Response::json(json_encode(array('error' => $msg)), $statusCode);
});
Event::listen("oauth2.error.redirect", function ($uri, $code) {
    $new_uri = $uri;
Example #3
0
    $oA = new SebRenauld\OAuth2();
    $i = Input::all();
    $r = $oA->finishClientAuthorization($i);
    return $r;
});
Route::get("/auth/authorize", function () {
    $oA = new SebRenauld\OAuth2();
    $i = Input::all();
    $r = $oA->getAuthorizeParams($i);
    if (!is_array($r)) {
        return $r;
    }
    return View::make("oauth2-sp::form", array("data" => $r));
});
Route::any("/auth/token", function () {
    $oA = new SebRenauld\OAuth2();
    $r = $oA->grantAccessToken(Input::all());
    if ($r instanceof Illuminate\Http\JsonResponse) {
        return $r;
    }
    if ($r instanceof SebRenauld\OAuth2\Models\Token) {
        return $r->printToken();
    }
});
/*
Route::post("/auth/token", function() {
	$oA = new SebRenauld\OAuth2();
	$r = $oA->grantAccessToken(Input::all());
	if ($r instanceof Response) {
		return $r;
	}