question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Making it easier to use the google-auth library in App Engine

See original GitHub issue

I had to jump through a number of hoops to get the requests transport working in the App Engine environment:

  1. Enable billing for the project
  2. Vendor in the requests-toolbelt library and enable the monkeypatch (as documented here)
  3. Add the ssl library to the app.yaml:
libraries:
- name: ssl
  version: latest
  1. Enable sockets as documented here

Only by doing all the above, that I could get the HTTPS request to Google OAuth2 token servers working. Is this to be expected? Is there anything that can be done to make using this library in App Engine easier?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

22reactions
hiranya911commented, Jul 14, 2017

Yes, I have the following in appengine_config.py:

from google.appengine.ext import vendor

vendor.add('lib')

I managed to resolve the module loading issue by using the following instead:

# appengine_config.py
import os
import google
from google.appengine.ext import vendor

lib_directory = os.path.dirname(__file__) + '/lib'

# Change where to find the google package (point to the lib/ directory)
google.__path__ = [os.path.join(lib_directory, 'google')] + google.__path__

# Add any libraries install in the "lib" folder.
vendor.add(lib_directory)

It would be nice if I could avoid having to do this though.

5reactions
jc275commented, Aug 31, 2017

I had the same ImportError with google.auth on dev_appserver as @hiranya911, whose workaround also fixed it for me.

@jonparrott Regarding the google.__path__ manipulations, I noticed that the following line was indeed necessary

google.__path__ = [os.path.join(lib_directory, 'google')] + google.__path__

whilst the following alternative didn’t solve the problem

google.__path__ = google.__path__ + [os.path.join(lib_directory, 'google')]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Auth Library: Node.js Client
This library provides an implementation of Application Default Credentialsfor Node.js. The Application Default Credentials provide a simple ...
Read more >
Authentication — google-api-core documentation
If you're running in Compute Engine or App Engine, authentication should “just work”. If you're developing locally, the easiest way to authenticate is...
Read more >
Using OAuth 2.0 with the Google API Client Library for Java
Overview. Purpose: This document explains how to use the GoogleCredential utility class to do OAuth 2.0 authorization with Google services.
Read more >
google.auth.app_engine module - Read the Docs
This module provides authentication and signing for applications running on App Engine in the standard environment using the App Identity API.
Read more >
Create a Flask Application With Google Login - Real Python
In fact, even the library you'll be using to make OAuth 2 and OIDC easier is usable in any Python code. In other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found