code: def authorized(remote_app=None):
      
      if remote_app not in current_oauthclient.handlers:
          return abort(404)
  
      state_token = request.args.get('state')
  
      # Verify state parameter
      try:
          assert state_token
          # Checks authenticity and integrity of state and decodes the value.
          state = serializer.loads(state_token)
          # Verify that state is for this session, app and that next parameter
          # have not been modified.
          assert state['sid'] == _create_identifier()
          assert state['app'] == remote_app
          # Store next URL
          set_session_next_url(remote_app, state['next'])
      except (AssertionError, BadData):
          if current_app.config.get('OAUTHCLIENT_STATE_ENABLED', True) or (
             not(current_app.debug or current_app.testing)):
              abort(403)
  
      try:
          handler = current_oauthclient.handlers[remote_app]()
      except OAuthException as e:
          if e.type == 'invalid_response':
              abort(500)
          else:
              raise
  
      return handler
docs: Authorized handler callback.