Facebook (OAuthException) This authorization code has been used.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hello all,

Since a few days I receive the following error when a user tries to login with the facebook plugin.

(OAuthException) This authorization code has been used.

I have found some info about this error on http://developers.facebook.com/bugs/121266004701942?browse=search_50c0a727cd8bd6850038373

Can it be fixed without code change?

Many thanks in advance,

Derck
11 years ago
I have same problem too. Does anyone know the cause?
11 years ago
As mentioned, the bug is documented here https://developers.facebook.com/bugs/121266004701942?browse=search_50c0a727cd8bd6850038373

To get the plugin working again for me, I adjusted FacebookProviderAuthorizer.cs to avoid calling GetAccessToken twice in the TranslateResponseState method.

From

private AuthorizeState TranslateResponseState(string returnUrl, FacebookOAuthResult oAuthResult)
        {
            if (oAuthResult.IsSuccess)
            {
                var parameters = new OAuthAuthenticationParameters(Provider.SystemName)
                {
                    ExternalIdentifier = GetAccessToken(oAuthResult.Code),
                    OAuthToken = oAuthResult.Code,
                    OAuthAccessToken = GetAccessToken(oAuthResult.Code)
                };
...


To

private AuthorizeState TranslateResponseState(string returnUrl, FacebookOAuthResult oAuthResult)
        {
            if (oAuthResult.IsSuccess)
            {
                var accessToken = GetAccessToken(oAuthResult.Code);
                var parameters = new OAuthAuthenticationParameters(Provider.SystemName)
                {
                    ExternalIdentifier = accessToken,
                    OAuthToken = oAuthResult.Code,
                    OAuthAccessToken = accessToken
                };
...


Seems to fix the issue
11 years ago
It worked for me. Thanks
11 years ago
Sorry for the delay, but it also worked for me. Thanks!
11 years ago
Great but i have no source ... how can i fix it in an existing installation ?

Thx
11 years ago
I've updated the code to the code above and I still get the error. What is the error actually trying to say?
10 years ago
Doesn't it mess with the facebook login authentication,
I change the code as you show

first time when associate accounts in login everything is ok
but then when I try to login with my facebook again it request my again to create a nopcommerce account
It's supposed to log me in isn't it? because I already associate with an account

Best regards
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.