Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bug in IdentityProvider.php getAccessToken function #10

Closed
scottzhang opened this issue Jul 9, 2013 · 3 comments
Closed

A bug in IdentityProvider.php getAccessToken function #10

scottzhang opened this issue Jul 9, 2013 · 3 comments

Comments

@scottzhang
Copy link

getAccessToken($grant = 'authorization_code', $params = array())
{
if (is_string($grant)) {
$grantPath = 'League\OAuth2\Client\Grant'.ucfirst(str_replace('_', '', $grant));

        if ( ! class_exists($grantPath)) {
            throw new \InvalidArgumentException('Unknown grant "'.$grant.'"');
        }

        $grantObj = new $grantPath;
    } elseif ( ! $grant instanceof Grant\GrantInterface) {
        throw new \InvalidArgumentException($grant.' is not an instance of \OAuth2\Client\Grant\GrantInterface');
    }

    $defaultParams = array(
        'client_id'     => $this->clientId,
        'client_secret' => $this->clientSecret,
        'redirect_uri'  => $this->redirectUri,
        'grant_type'    => $grant,
    );

....
return $grantObj->handleResponse($result);
This is my fix. The problem is the pass in $grant get override by the class path, then become the grant object. Then the grant object assigned to $defaultParams, which fail the whole process. I changed the code to keep original $grant untouched. And use $grantPath for class path. And $grantObj for grant object.

@philsturgeon
Copy link
Member

Could you send this in as a pull request?

@scottzhang
Copy link
Author

I don't know how to "new pull request". When I click "new pull request", it show me the page to compare branches.

@philsturgeon
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants