code: def create_authorization_code(self, request):
          
          grant = {'code': common.generate_token()}
          if hasattr(request, 'state') and request.state:
              grant['state'] = request.state
          log.debug('Created authorization code grant %r for request %r.',
                    grant, request)
          return grant
docs: Generates an authorization grant represented as a dictionary.
  
          :param request: OAuthlib request.
          :type request: oauthlib.common.Request