コード例 #1
0
  def _do_process(self, req):
    """Process grant returned by user.
    """
    code = req.args.get('code')
    next = req.args.get('state') or req.base_path or "/"
    if not code: 
      raise HTTPBadRequest('"code" parameter is missing.')

    try:
      access_token = oauth2.process_code(code)
    except ValueError, err:
      raise HTTPBadRequest('Bad request. %s' % err)
コード例 #2
0
ファイル: wsgi.py プロジェクト: AF83/auth_server_client_py
  def process(self, request, environ, start_response):
    code = request.GET.get('code')
    # TODO: if not code: abort(401)

    try:
      access_token = oauth2.process_code(code)
    except ValueError:
      start_response('400 Bad request', [])
      return ['']

    if access_token is None:
      start_response('401 Unauthorized', [])
      return ['']

    try:
      info = oauth2.get_authorizations(access_token)
    except ValueError, err:
      start_response('500 Internal Server Error', [])
      return ['%s' % err]
コード例 #3
0
 def test_right_answer(self):
   # AuthServer answer with access_token (correct format)
   self.furlopen_result = StringIO('{"access_token": "sometoken"}')
   token = oauth2.process_code('code')
   self.assertEqual(token, "sometoken")