| Index: third_party/oauth2client/clientsecrets.py
 | 
| diff --git a/third_party/oauth2client/clientsecrets.py b/third_party/oauth2client/clientsecrets.py
 | 
| index ac99aae969f17c9b71787cfb5bc4984f0b8055af..af079ecc997025183b7fec37c7a4ff3f06c3a705 100644
 | 
| --- a/third_party/oauth2client/clientsecrets.py
 | 
| +++ b/third_party/oauth2client/clientsecrets.py
 | 
| @@ -1,4 +1,4 @@
 | 
| -# Copyright (C) 2011 Google Inc.
 | 
| +# Copyright 2014 Google Inc. All rights reserved.
 | 
|  #
 | 
|  # Licensed under the Apache License, Version 2.0 (the "License");
 | 
|  # you may not use this file except in compliance with the License.
 | 
| @@ -20,8 +20,10 @@ an OAuth 2.0 protected service.
 | 
|  
 | 
|  __author__ = 'jcgregorio@google.com (Joe Gregorio)'
 | 
|  
 | 
| +import json
 | 
| +
 | 
| +from third_party import six
 | 
|  
 | 
| -from anyjson import simplejson
 | 
|  
 | 
|  # Properties that make a client_secrets.json file valid.
 | 
|  TYPE_WEB = 'web'
 | 
| @@ -68,11 +70,21 @@ class InvalidClientSecretsError(Error):
 | 
|  
 | 
|  
 | 
|  def _validate_clientsecrets(obj):
 | 
| -  if obj is None or len(obj) != 1:
 | 
| -    raise InvalidClientSecretsError('Invalid file format.')
 | 
| -  client_type = obj.keys()[0]
 | 
| -  if client_type not in VALID_CLIENT.keys():
 | 
| -    raise InvalidClientSecretsError('Unknown client type: %s.' % client_type)
 | 
| +  _INVALID_FILE_FORMAT_MSG = (
 | 
| +    'Invalid file format. See '
 | 
| +    'https://developers.google.com/api-client-library/'
 | 
| +    'python/guide/aaa_client_secrets')
 | 
| +
 | 
| +  if obj is None:
 | 
| +    raise InvalidClientSecretsError(_INVALID_FILE_FORMAT_MSG)
 | 
| +  if len(obj) != 1:
 | 
| +    raise InvalidClientSecretsError(
 | 
| +      _INVALID_FILE_FORMAT_MSG + ' '
 | 
| +      'Expected a JSON object with a single property for a "web" or '
 | 
| +      '"installed" application')
 | 
| +  client_type = tuple(obj)[0]
 | 
| +  if client_type not in VALID_CLIENT:
 | 
| +    raise InvalidClientSecretsError('Unknown client type: %s.' % (client_type,))
 | 
|    client_info = obj[client_type]
 | 
|    for prop_name in VALID_CLIENT[client_type]['required']:
 | 
|      if prop_name not in client_info:
 | 
| @@ -87,22 +99,19 @@ def _validate_clientsecrets(obj):
 | 
|  
 | 
|  
 | 
|  def load(fp):
 | 
| -  obj = simplejson.load(fp)
 | 
| +  obj = json.load(fp)
 | 
|    return _validate_clientsecrets(obj)
 | 
|  
 | 
|  
 | 
|  def loads(s):
 | 
| -  obj = simplejson.loads(s)
 | 
| +  obj = json.loads(s)
 | 
|    return _validate_clientsecrets(obj)
 | 
|  
 | 
|  
 | 
|  def _loadfile(filename):
 | 
|    try:
 | 
| -    fp = file(filename, 'r')
 | 
| -    try:
 | 
| -      obj = simplejson.load(fp)
 | 
| -    finally:
 | 
| -      fp.close()
 | 
| +    with open(filename, 'r') as fp:
 | 
| +      obj = json.load(fp)
 | 
|    except IOError:
 | 
|      raise InvalidClientSecretsError('File not found: "%s"' % filename)
 | 
|    return _validate_clientsecrets(obj)
 | 
| @@ -114,10 +123,12 @@ def loadfile(filename, cache=None):
 | 
|    Typical cache storage would be App Engine memcache service,
 | 
|    but you can pass in any other cache client that implements
 | 
|    these methods:
 | 
| -    - get(key, namespace=ns)
 | 
| -    - set(key, value, namespace=ns)
 | 
|  
 | 
| -  Usage:
 | 
| +  * ``get(key, namespace=ns)``
 | 
| +  * ``set(key, value, namespace=ns)``
 | 
| +
 | 
| +  Usage::
 | 
| +
 | 
|      # without caching
 | 
|      client_type, client_info = loadfile('secrets.json')
 | 
|      # using App Engine memcache service
 | 
| @@ -150,4 +161,4 @@ def loadfile(filename, cache=None):
 | 
|      obj = {client_type: client_info}
 | 
|      cache.set(filename, obj, namespace=_SECRET_NAMESPACE)
 | 
|  
 | 
| -  return obj.iteritems().next()
 | 
| +  return next(six.iteritems(obj))
 | 
| 
 |