When I try to follow this tutorial to install Google-auth2 on my Django 1.4 I get this error:
Traceback (most recent call last):
File "./manage.py", line 11, in <module>
import settings
File "/home/ubuntu/xx/settings.py", line 140, in <module>
GOOGLE_OAUTH2_CLIENT_ID = os.environ['GOOGLE_OAUTH2_CLIENT_ID']
NameError: name 'os' is not defined
This line is:
139- LOGIN_REDIRECT_URL = '/'
**140- GOOGLE_OAUTH2_CLIENT_ID = os.environ['GOOGLE_OAUTH2_CLIENT_ID']**
141- GOOGLE_OAUTH2_CLIENT_SECRET = os.environ['GOOGLE_OAUTH2_CLIENT_SECRET']
142- GOOGLE_WHITE_LISTED_DOMAINS = ['mydomain.org']
SOCIAL_AUTH_USER_MODEL = 'auth.User'
You try to use something from module
os, which is not imported, thus you cannot use it.In order to fix this problem, add an import of that module somewhere at the beginning of
settings.py:Additionally, if you don’t have
GOOGLE_OAUTH2_CLIENT_IDinos.environ, don’t load it from there. Instead, set it directly insettings.py:Or, you can set it first, in your shell, before running the script: