code: def build_auth_uri(endpoint, client_id, redirect_uri=None, scope=None, state=None):
          
          params = {'response_type': 'code', 'client_id': client_id}
          if redirect_uri is not None:
              params['redirect_uri'] = redirect_uri
  
          if scope is not None:
              params['scope'] = ' '.join(scope)
  
          if state is not None:
              params['state'] = state
  
          return '%s?%s' % (endpoint, urlencode(params))
docs: Helper method builds the uri that a user must be redirected to for
          authentication/authorization using the authorization_code grant type.
  
              endpoint - The authorization endpoint
  
              client_id - The client id
  
              redirect_uri - The redirect uri
  
              scope - A list of permissions to request
  
              state - An application state that will be sent back by the
                authorization server