title: Using Google OAuth on localhost
body: <p>I started to use OAuth with Python and Django. I need it for Google APIs. I working on localhost, so I can't register a domain for url-callback. I've read about that Google OAuth could be used with anonymous domain. Can't find, how and where I can do that?</p>
  
  <h2>Edit:</h2>
  
  <p>I have this view:</p>
  
  <pre><code>def authentication(request):
      CONSUMER_KEY = 'xxxxx'
      CONSUMER_SECRET = 'xxxxx'
      SCOPES = ['https://docs.google.com/feeds/', ]
  
      client = gdata.docs.client.DocsClient(source='apiapp')
      oauth_callback_url = 'http://%s/get_access_token' % request.META.get('HTTP_HOST')
      request_token = client.GetOAuthToken(
        SCOPES, oauth_callback_url, CONSUMER_KEY, consumer_secret=CONSUMER_SECRET)
     domain = '127.0.0.1:8000'
     return HttpResponseRedirect(
          request_token.generate_authorization_url(google_apps_domain=domain))
  </code></pre>
  
  <p>And this error:</p>
  
  <blockquote>
    <p>Sorry, you've reached a login page for a domain that isn't using Google Apps. Please check the web address and try again.</p>
  </blockquote>
  
  <p>Registered via <a href="https://code.google.com/apis/console/">https://code.google.com/apis/console/</a></p>
  
  <h2>Edit:</h2>
  
  <pre><code>CONSUMER_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
  CONSUMER_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxx'
  SCOPES = ['https://docs.google.com/feeds/', ]
  DOMAIN = 'localhost:8000'
  
  
  def authentication(request):    
      client = gdata.docs.client.DocsClient(source='apiapp')
      oauth_callback_url = 'http://%s/get_access_token' % DOMAIN
  
      request_token = client.GetOAuthToken(SCOPES,
                                       oauth_callback_url,
                                       CONSUMER_KEY,
                                       consumer_secret=CONSUMER_SECRET)
  
      return HttpResponseRedirect(
          request_token.generate_authorization_url())
  
  
  def verify(request):
      client = gdata.docs.client.DocsClient(source='apiapp')
      f = open('/home/i159/.ssh/id_rsa')
      RSA_KEY = f.read()
      f.close()
  
      oauth_callback_url = 'http://%s/get_access_token' % DOMAIN
  
      request_token = client.GetOAuthToken(SCOPES,
                                       oauth_callback_url,
                                       CONSUMER_KEY,
                                       rsa_private_key=RSA_KEY)
      return HttpResponseRedirect(
          request_token.generate_authorization_url(google_apps_domain=DOMAIN))
  </code></pre>
  
  <p>The error: </p>
  
  <blockquote>
    <p>Unable to obtain OAuth request token: 400, Consumer does not have a cert: xxxxxxxxxxxxxxx.apps.googleusercontent.com</p>
  </blockquote>