code: def extract_client_auth(request):
      
      auth_header = request.META.get('HTTP_AUTHORIZATION', '')
  
      if re.compile('^Basic\s{1}.+$').match(auth_header):
          b64_user_pass = auth_header.split()[1]
          try:
              user_pass = b64decode(b64_user_pass).decode('utf-8').split(':')
              client_id, client_secret = tuple(user_pass)
          except Exception:
              client_id = client_secret = ''
      else:
          client_id = request.POST.get('client_id', '')
          client_secret = request.POST.get('client_secret', '')
  
      return (client_id, client_secret)
docs: Get client credentials using HTTP Basic Authentication method.
      Or try getting parameters via POST.
      See: http://tools.ietf.org/html/rfc6750#section-2.1
  
      Return a tuple `(client_id, client_secret)`.