title: Error authenticating with OAuth in Python
body: <p>I'm trying to learn how to utilize OAuth for an application I'm developing, and I can't seem to wrap my head around the verification code part and the point of a redirect URI. Here's what I have.. I don't understand the point of a redirect URI, and once I do get a valid verification code. How would I even go about pulling in calendar events from Google for the user in JSON?</p>
  
  <pre><code>from pyoauth2 import Client
  
  CLIENT_ID = 'XXXXXXXXXXXXXX'
  CLIENT_SECRET = 'XXXXXXXXXXXXXX'
  REDIRECT_URL = 'XXXXXXXXXXXXXX'
  SCOPE = 'https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/userinfo.email'
  
  client = Client(CLIENT_ID, CLIENT_SECRET,
              site='https://www.googleapis.com/oauth2/v1',
              authorize_url='https://accounts.google.com/o/oauth2/auth',
              token_url='https://accounts.google.com/o/oauth2/token')
  
  print '-' * 80
  authorize_url = client.auth_code.authorize_url(redirect_uri=REDIRECT_URL, scope=SCOPE)
  print 'Go to the following link in your browser:'
  print authorize_url
  
  code = raw_input('Enter the verification code and hit ENTER when you re done:')
  code = code.strip()
  access_token = client.auth_code.get_token(code, redirect_uri=REDIRECT_URL)
  print 'token', access_token.headers
  
  print '-' * 80
  print 'get user info' 
  ret = access_token.get('/userinfo')
  print ret.parsed
  </code></pre>
  
  <p>Oops.. forgot the error.. I'm not even sure what a verification code should look like.</p>
  
  <pre><code>token {'Authorization': 'Bearer '}
  --------------------------------------------------------------------------------
  get user info
  {u'error': {u'code': 401, u'message': u'Invalid Credentials', u'errors': [{u'locationType': u'header', u'domain': u'global', u'message': u'Invalid Credentials', u'reason': u'authError', u'location': u'Authorization'}]}}
  </code></pre>