wohali / oauth2-discord-new

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

Error when update the page #12

Closed StrangerGithuber closed 5 years ago

StrangerGithuber commented 5 years ago

Hello When I am updating the page then I get this error message: Fatal error: Uncaught exception 'Wohali\OAuth2\Client\Provider\Exception\DiscordIdentityProviderException' with message '{"error":"invalid_grant"}' in C:\xampp56\htdocs\discordapp\vendor\wohali\oauth2-discord-new\src\Provider\Exception\DiscordIdentityProviderException.php:47 Stack trace: #0 C:\xampp56\htdocs\discordapp\vendor\wohali\oauth2-discord-new\src\Provider\Exception\DiscordIdentityProviderException.php(34): Wohali\OAuth2\Client\Provider\Exception\DiscordIdentityProviderException::fromResponse(Object(GuzzleHttp\Psr7\Response), '{"error":"inval...') #1 C:\xampp56\htdocs\discordapp\vendor\wohali\oauth2-discord-new\src\Provider\Discord.php(110): Wohali\OAuth2\Client\Provider\Exception\DiscordIdentityProviderException::clientException(Object(GuzzleHttp\Psr7\Response), Array) #2 C:\xampp56\htdocs\discordapp\vendor\league\oauth2-client\src\Provider\AbstractProvider.php(613): Wohali\OAuth2\Client\Provider\Discord->checkResponse(Object(GuzzleHttp\Psr7\Response), Array) #3 C:\xampp56\htdocs\discordapp\vendor\league\oauth2-c in C:\xampp56\htdocs\discordapp\vendor\wohali\oauth2-discord-new\src\Provider\Exception\DiscordIdentityProviderException.php on line 47

In the url there is the state and the code thought. I don't understand why I get this then. I am redirected to discord and I click to Authorize and it works but if I refresh the page then I get the above message. I did as in example was.

If I click somewhere else then I will be redirected again to the discord page.

HayateLaTech commented 5 years ago

1

--> please try to look in the already closed issues if your problem was already adressed at some point.

StrangerGithuber commented 5 years ago

I don't understand what variable I need to save but ok. 👍

wohali commented 5 years ago

Thanks for the help while I was busy with other things, @HayateLaTech !

danbulant commented 5 years ago

@StrangerGithuber You need to save refreshToken and use it in refresh_token grant: $_SESSION["token"] = $token->getRefreshToken(); $token = $provider->getAccessToken('refresh_token', [ 'refresh_token' => $_SESSION["token"] ]);