AuthFailed, AuthCanceled, \
                                             AuthUnknownError, AuthTokenError, \
                                             AuthMissingParameter, \
-                                            AuthForbidden
+                                            AuthStateMissing, \
+                                            AuthStateForbidden
 from social_auth.backends.utils import build_consumer_oauth_request
 
 
             raise AuthFailed(self, error)
 
         if self.FORCE_STATE_CHECK:
-            if 'state' not in self.data:
+            request_state = self.data.get('state')
+            state = self.request.session.get(self.AUTH_BACKEND.name + '_state')
+            if not request_state:
                 raise AuthMissingParameter(self, 'state')
-            state = self.request.session[self.AUTH_BACKEND.name + '_state']
-            if not constant_time_compare(self.data['state'], state):
-                raise AuthForbidden(self)
+            elif not state:
+                raise AuthStateMissing(self, 'state')
+            elif not constant_time_compare(request_state, state):
+                raise AuthStateForbidden(self)
 
         client_id, client_secret = self.get_key_and_secret()
         params = {'grant_type': 'authorization_code',  # request auth code
 
     ACCESS_TOKEN_URL = 'http://api.odnoklassniki.ru/oauth/token.do'
     SETTINGS_KEY_NAME = 'ODNOKLASSNIKI_OAUTH2_CLIENT_KEY'
     SETTINGS_SECRET_NAME = 'ODNOKLASSNIKI_OAUTH2_CLIENT_SECRET'
+    FORCE_STATE_CHECK = False
 
     def get_scope(self):
         return setting('ODNOKLASSNIKI_OAUTH2_EXTRA_SCOPE', [])
 
         return u'Missing needed parameter %s' % self.parameter
 
 
-class AuthForbidden(AuthException):
+class AuthStateMissing(AuthException):
+    """State parameter is incorrect."""
+    def __unicode__(self):
+        return u'Session value state missing.'
+
+
+class AuthStateForbidden(AuthException):
     """State parameter is incorrect."""
     def __unicode__(self):
         return u'Wrong state parameter given.'