wohali / oauth2-discord-new

New Discord Provider for the OAuth 2.0 Client
MIT License
118 stars 22 forks source link

Got error 'PHP message: PHP Fatal error: Uncaught #20

Closed bymem closed 5 years ago

bymem commented 5 years ago

Hi i keeps getting a uncaught error. even after i still is getting the user information.

[Tue Nov 27 20:02:14.896224 2018] [proxy_fcgi:error] [pid 2997] [client 2.106.184.79:45514] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Wohali\\OAuth2\\Client\\Provider\\Exception
\\DiscordIdentityProviderException: {"error":"invalid_grant"} in vendor/wohali/oauth2-discord-new/src
/Provider/Exception/DiscordIdentityProviderException.php:47\nStack trace:\n#0 vendor/wohali/oauth2-di
scord-new/src/Provider/Exception/DiscordIdentityProviderException.php(33): Wohali\\OAuth2\\Client\\Provider\\Exception\\DiscordIdentityProviderException::fromResponse(Object(GuzzleHttp\\Psr7\\Res
ponse), '{"error":"inval...')\n#1 /vendor/wohali/oauth2-discord-new/src/Provider/Discord.php(110): Woh
ali\\OAuth2\\Client\\Provider\\Exception\\DiscordIdentityProviderException::clientException(Object(GuzzleHttp\\Psr7\\Response), Array)\n#2 /htt...\n'

i'm just jusing simply version of the example

nclude(PLUGIN_DIR . '/vendor/autoload.php');

        $provider = new \Wohali\OAuth2\Client\Provider\Discord([
            'clientId'     => '***',
            'clientSecret' => '***',
            'redirectUri'  => '***',
        ]);

        $token = $provider->getAccessToken('authorization_code', [
            'code' => $_GET['code'],
        ]);

        try {

            $user = $provider->getResourceOwner($token);

            echo '<h2>Resource owner details:</h2>';
            printf('Hello %s#%s!<br/><br/>', $user->getUsername(), $user->getDiscriminator());

            print_r($user);

        } catch (Exception $e) {

            // Failed to get user details
            //exit('Oh dear...');

        }
danbulant commented 5 years ago

How did you fixed that? I'm having same issue