bshaffer / oauth2-server-php-docs

documentation for the oauth2-server-php library
231 stars 148 forks source link

Docs are wrong on validateAuthorizeRequest #22

Open bshaffer opened 10 years ago

bshaffer commented 10 years ago

from https://github.com/bshaffer/oauth2-server-php/issues/231

I've just upgraded from an older version of this library to the latest on my server. Most everything seems to be working fine, however, I cannot seem to get the validateAuthorizeRequest function to return an array of client data as it did before.

public function displayAuth()
    {
        # validate the authorize request
        $request = OAuth2\Request::createFromGlobals();
        $response = new OAuth2\Response();
        if (!$clientdata = $this->server->validateAuthorizeRequest($request, $response)) {
            $response->send();
            die;
        }

        # display an authorization form
        if (empty($_POST)) {
            return View::make("layouts.api")->nest("child", "api.auth", array("status" => "form", "client" => $clientdata));
        }

    }

I'm using a Laravel controller to route API functions - it's constructed in the following manner.

class OAuthController extends BaseController {

    protected $server, $storage;

    public function __construct()
    {
        # register the autoloader
        require_once('/fake/path/to/oauth2-server/src/OAuth2/Autoloader.php');
        OAuth2\Autoloader::register();

        $storage = new OAuth2\Storage\Pdo([connection info array]);

        # Pass a storage object or array of storage objects to the OAuth2 server class
        $server = new OAuth2\Server($storage);

        # set up scopes
        $memory = new OAuth2\Storage\Memory(array(
            'default_scope' => 'profile',
            'supported_scopes' => array(
                'profile',
                'email',
                'sensitive'
            )
        ));
        $server->setScopeUtil(new OAuth2\Scope($memory));

        $this->server = $server;
        $this->storage = $storage;
    }

[other stuff here]

A quick var_dump() on the client variable returns bool(true). However, the documentation states that validateAuthorizeRequest returns false or an array of client data. Has this changed?

pushad commented 8 years ago

I too would like to know more on this. For now the information is available through the public methods it seems, i.e. getClientId();

bshaffer commented 8 years ago

The documentation has always been wrong here (new link).