def Create(email_address=None, private_key_path=None, oauth_url=None):
        if email_address:
            from google.appengine.api.app_identity import app_identity_keybased_stub

            logging.debug('Using the KeyBasedAppIdentityServiceStub.')
            return app_identity_keybased_stub.KeyBasedAppIdentityServiceStub(
                email_address=email_address,
                private_key_path=private_key_path,
                oauth_url=oauth_url)
        elif sys.version_info >= (2, 6):
            from oauth2client import client
            from google.appengine.api.app_identity import app_identity_defaultcredentialsbased_stub as ai_stub
            try:
                dc = ai_stub.DefaultCredentialsBasedAppIdentityServiceStub()
                logging.debug(
                    'Successfully loaded Application Default Credentials.')
                return dc
            except client.ApplicationDefaultCredentialsError, error:
                if not str(error).startswith(
                        'The Application Default Credentials '
                        'are not available.'):
                    logging.warning(
                        'An exception has been encountered when attempting '
                        'to use Application Default Credentials: %s'
                        '. Falling back on dummy AppIdentityServiceStub.',
                        str(error))
                return AppIdentityServiceStub()
    def Create(email_address=None, private_key_path=None):
        if email_address:
            from google.appengine.api.app_identity import app_identity_keybased_stub

            return app_identity_keybased_stub.KeyBasedAppIdentityServiceStub(
                email_address=email_address, private_key_path=private_key_path)
        else:
            return AppIdentityServiceStub()
Example #3
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        # Then activate the testbed, which prepares the service stubs for use.
        self.testbed.activate()
        # Next, declare which service stubs you want to use.
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_urlfetch_stub()

        from google.appengine.api.app_identity import app_identity_stub
        from google.appengine.api.app_identity import app_identity_keybased_stub
        email_address = local_config.SERVICE_EMAIL
        private_key_path = local_config.SERVICE_KEY_FILE
        stub = app_identity_keybased_stub.KeyBasedAppIdentityServiceStub(email_address=email_address,
                                                                         private_key_path=private_key_path)
        self.testbed._register_stub(testbed.APP_IDENTITY_SERVICE_NAME, stub)
Example #4
0
    def Create(email_address=None, private_key_path=None, oauth_url=None):
        if email_address:
            logging.debug('Using the KeyBasedAppIdentityServiceStub.')
            return app_identity_keybased_stub.KeyBasedAppIdentityServiceStub(
                email_address=email_address,
                private_key_path=private_key_path,
                oauth_url=oauth_url)
        else:
            try:
                dc = ai_default_stub.DefaultCredentialsBasedAppIdentityServiceStub(
                )
                logging.debug(
                    'Successfully loaded Application Default Credentials.')
                return dc
            except exceptions.DefaultCredentialsError as error:
                if not str(error).startswith(
                        'Could not automatically determine credentials.'):

                    logging.warning(
                        'An exception has been encountered when attempting '
                        'to use Application Default Credentials: %s'
                        '. Falling back on dummy AppIdentityServiceStub.',
                        str(error))
                return AppIdentityServiceStub()
Example #5
0
# run with py.test

if 1:
    from google.appengine.ext import testbed
    from google.appengine.api.app_identity import app_identity_stub
    from google.appengine.api.app_identity import app_identity_keybased_stub
    import local_config
    email_address = local_config.SERVICE_EMAIL
    private_key_path = local_config.SERVICE_KEY_FILE
    stub = app_identity_keybased_stub.KeyBasedAppIdentityServiceStub(
        email_address=email_address, private_key_path=private_key_path)
    testbed = testbed.Testbed()
    APP_IDENTITY_SERVICE_NAME = 'app_identity_service'
    testbed.activate()
    #testbed._register_stub(testbed.APP_IDENTITY_SERVICE_NAME, stub)
    testbed._register_stub(APP_IDENTITY_SERVICE_NAME, stub)
    testbed.init_datastore_v3_stub()
    testbed.init_memcache_stub()
    testbed.init_urlfetch_stub()

    from google.appengine.ext import testbed
    testbed = testbed.Testbed()
    testbed.activate()
    testbed.init_datastore_v3_stub()
    testbed.init_memcache_stub()

from bqutil import *