wohali / oauth2-discord-new

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

Error after F5 #1

Closed bet0x closed 7 years ago

bet0x commented 7 years ago

I did follow the basic example, i had to remove this line:

echo ('Main screen turn on!<br/><br/>'); because "headers sent" error.

After that i get the example running, but after i get redirected from my site to discord and back and then F5 on the same page i get that error.

Fatal error: Uncaught exception 'Wohali\OAuth2\Client\Provider\Exception\DiscordIdentityProviderException' with message '{"error":"invalid_grant"}'

HayateLaTech commented 7 years ago

The thing is, that if you press F5 the whole page reloads, meaning that the OAuth Provider tries to do the workflow again with the same information which isnt possible anymore because you're only allowed to exchange the access-token once - after the first exchange it's not possible to do it again. So you'll have to either save the variables you need in the session or in a db, etc. OR you use the access-token to get the information again, but you cannot use the get-parameter of code again to get the access-token.