Add GAE to application default credentials.
diff --git a/google/auth/_default.py b/google/auth/_default.py
index 3f6993a..74b96b3 100644
--- a/google/auth/_default.py
+++ b/google/auth/_default.py
@@ -23,6 +23,7 @@
import os
from google.auth import _cloud_sdk
+from google.auth import app_engine
from google.auth import compute_engine
from google.auth import environment_vars
from google.auth import exceptions
@@ -150,7 +151,12 @@
def _get_gae_credentials():
"""Gets Google App Engine App Identity credentials and project ID."""
- return None, None
+ try:
+ credentials = app_engine.Credentials()
+ project_id = app_engine.get_project_id()
+ return credentials, project_id
+ except EnvironmentError:
+ return None, None
def _get_gce_credentials(request=None):
diff --git a/google/auth/app_engine.py b/google/auth/app_engine.py
index 6f32b23..d20ddf6 100644
--- a/google/auth/app_engine.py
+++ b/google/auth/app_engine.py
@@ -33,6 +33,21 @@
app_identity = None
+def get_project_id():
+ """Gets the project ID for the current App Engine application.
+
+ Returns:
+ str: The project ID
+
+ Raises:
+ EnvironmentError: If the App Engine APIs are unavailable.
+ """
+ if app_identity is None:
+ raise EnvironmentError(
+ 'The App Engine APIs are not available.')
+ return app_identity.get_application_id()
+
+
class Credentials(credentials.Scoped, credentials.Signing,
credentials.Credentials):
"""App Engine standard environment credentials.