title: Django OAuth2 Error: invalid_client and client_id=None when client_id has been provided
body: <p>I am using django-social-auth for google apps authentication for my django project. I obtained the client id and secret key from Google api console for my domain. And plugged in the values in my app as follows:</p>
  
  <pre><code>    **settings.py**
  
        MIDDLEWARE_CLASSES = (
        'social_auth.middleware.SocialAuthExceptionMiddleware',
        )
  
       LOGIN_URL = '/login/google-oauth2/'
       LOGIN_REDIRECT_URL = '/profile'
       LOGIN_ERROR_URL = '/login-error/'
  
       AUTHENTICATION_BACKENDS = (
        'social_auth.backends.google.GoogleOAuth2Backend',
        'django.contrib.auth.backends.ModelBackend',
       )
  
      TEMPLATE_CONTEXT_PROCESSORS = (
       "django.contrib.auth.context_processors.auth",
       "social_auth.context_processors.social_auth_by_type_backends",
      )
  
      SOCIAL_AUTH_ENABLED_BACKENDS = ('google',)
      SOCIAL_AUTH_DEFAULT_USERNAME = 'new_social_auth_user'
  
      GOOGLE_OAUTH2_CLIENT_ID = '***.apps.googleusercontent.com'
      GOOGLE_OAUTH2_CLIENT_SECRET = '****'
      GOOGLE_WHITE_LISTED_DOMAINS = ['127.0.0.1:8000']
  
      SOCIAL_AUTH_COMPLETE_URL_NAME  = 'socialauth_complete'
      SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'socialauth_associate_complete'
      SOCIAL_AUTH_RAISE_EXCEPTIONS = False
      SOCIAL_AUTH_PROCESS_EXCEPTIONS = 'social_auth.utils.log_exceptions_to_messages'  
  
      INSTALLED_APPS = (
              'social_auth', )
  </code></pre>
  
  <p>...</p>
  
  <pre><code>    **urls.py**
  
       from django.conf.urls import patterns, include, url
       from django.contrib import admin
       from django.views.generic import TemplateView
       from django.contrib.auth.views import logout
       admin.autodiscover()
  
       urlpatterns = patterns('',
  
       url(r'^admin/', include(admin.site.urls)),
       url(r'', include('social_auth.urls')),
       url(r'^$', TemplateView.as_view(template_name="login.html")),                 
       url(r'^logout/$', logout, {'next_page': '/'}, name='gauth_logout'),
       url(r'^profile/$', TemplateView.as_view(template_name="profile.html")),
       )
  </code></pre>
  
  <p>...</p>
  
  <pre><code>     **login.html**
  
       &lt;p&gt;Use your work email credentials to sign in to this application: 
       &lt;a href="{% url 'socialauth_begin' 'google-oauth2' %}"&gt;Sign In&lt;/a&gt;
        &lt;/p&gt;
  </code></pre>
  
  <p>The problem is that when I click on sign in I am redirected to the Error: Invalid_client page with the details:</p>
  
  <pre><code>      Request Details
        cookie_policy_enforce=false
        scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
        response_type=code
        redirect_uri=http://127.0.0.1:8000/complete/google-oauth2/
        state=WZWyJgDRfeW4RneRynqSZ3nSy0Bzs0v6
        client_id=None
  </code></pre>
  
  <p><a href="https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&amp;state=WZWyJgDRfeW4RneRynqSZ3nSy0Bzs0v6&amp;redirect_uri=http://127.0.0.1:8000/complete/google-oauth2/&amp;response_type=code&amp;client_id=None" rel="nofollow">https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&amp;state=WZWyJgDRfeW4RneRynqSZ3nSy0Bzs0v6&amp;redirect_uri=http://127.0.0.1:8000/complete/google-oauth2/&amp;response_type=code&amp;client_id=None</a></p>
  
  <p>Even though I have provided the correct client_id in my project, the page (and as can be seen from the url) says that it has not been provided. If I plug it manually in the url, I am redirected to the permissions page though.</p>
  
  <p>Also when I accept the permissions I get an <strong>AuthCanceled at /complete/google-oauth2/</strong> error. Is it that my project is not reading the social_auth settings correctly?</p>
  
  <p>Any help would be appreciated. Thanks.</p>